by Tarowd (1 Submission)
Category: Windows API Call/Explanation
Compatability: Visual Basic 4.0 (32-bit)
Difficulty: Unknown Difficulty
Originally Published: Mon 14th August 2006
Date Added: Mon 8th February 2021
Rating: (1 Votes)
Send mails to remote comuter. No dialogs.
API Declarations
Public Const conMailListView = 1
Public Const conOptionGeneral = 1 ' Constant for Option Dialog Type - General Options
Public Const conOptionMessage = 2 ' Constant for Option Dialog Type - Message Options
Public Const vbRecipTypeTo = 1
Public Const vbRecipTypeCc = 2
Public Const vbMessageFetch = 1
Public Const vbMessageSendDlg = 2
Public Const vbMessageSend = 3
Public Const vbMessageSaveMsg = 4
Public Const vbMessageCopy = 5
Public Const vbMessageCompose = 6
Public Const vbMessageReply = 7
Public Const vbMessageReplyAll = 8
Public Const vbMessageForward = 9
Public Const vbMessageDelete = 10
Public Const vbMessageShowAdBook = 11
Public Const vbMessageShowDetails = 12
Public Const vbMessageResolveName = 13
Public Const vbRecipientDelete = 14
Public Const vbAttachmentDelete = 15
Public Const vbAttachTypeData = 0
Public Const vbAttachTypeEOLE = 1
Public Const vbAttachTypeSOLE = 2
Declare Function AddAccessAllowedAce Lib "advapi32.dll" Alias "AddAccessAllowedAce" (pAcl As ACL, ByVal dwAceRevision As Long, ByVal AccessMask As Long, pSid As Any) As Long
Declare Function AppendMenu Lib "user32" Alias "AppendMenuA" (ByVal hMenu As Long, ByVal wFlags As Long, ByVal wIDNewItem As Long, ByVal lpNewItem As String) As Long
Declare Function GetPrivateObjectSecurity Lib "advapi32.dll" Alias "GetPrivateObjectSecurity" (ObjectDescriptor As SECURITY_DESCRIPTOR, ByVal SecurityInformation As Long, ResultantDescriptor As SECURITY_DESCRIPTOR, ByVal DescriptorLength As Long, ReturnLength As Long) As Long
Declare Function WritePrivateProfileString Lib "kernel32" Alias "WritePrivateProfileStringA" (ByVal lpApplicationName As String, ByVal lpKeyName As Any, ByVal lpString As Any, ByVal lpFileName As String) As Long
' Declare local variables.
Dim MsgText
Dim PB
' Initialize the paragraph break variable.
PB = Chr(10) & Chr(13) & Chr(10) & Chr(13)
' Display the instructions.
MsgText = "To insert a new object, choose New from the File menu, and then select an object from the Insert Object dialog box."
MsgText = MsgText & PB & "Once you have saved an inserted object using the Save As command, you can use the Open command on the File menu to view the object in subsequent sessions."
MsgText = MsgText & PB & "To edit an object, double-click the object to display the editing environment for the application from which the object originated."
MsgText = MsgText & PB & "Click the object with the right mouse button to view the object's verbs."
MsgText = MsgText & PB & "Use the Copy, Delete, and Paste Special commands to copy, delete, and paste objects."
MsgText = MsgText & PB & "Choose the Update command to update the contents of the insertable object."
MsgBox MsgText, 64, "OLE Container Control Demo Instructions"
End Sub
Sub Attachments(Msg As Form)
' Clear the current attachment list.
Msg.aList.Clear
' If there are attachments, load them into the list box.
If VBMail.MapiMess.AttachmentCount Then
Msg.NumAtt = VBMail.MapiMess.AttachmentCount & " Files"
For i% = 0 To VBMail.MapiMess.AttachmentCount - 1
VBMail.MapiMess.AttachmentIndex = i%
a$ = VBMail.MapiMess.AttachmentName
Select Case VBMail.MapiMess.AttachmentType
Case vbAttachTypeData
a$ = a$ + " (Data File)"
Case vbAttachTypeEOLE
a$ = a$ + " (Embedded OLE Object)"
Case vbAttachTypeSOLE
a$ = a$ + " (Static OLE Object)"
Case Else
a$ = a$ + " (Unknown attachment type)"
End Select
Msg.aList.AddItem a$
Next i%
If Not Msg.AttachWin.Visible Then
Msg.AttachWin.Visible = True
Call SizeMessageWindow(Msg)
' If Msg.WindowState = 0 Then
' Msg.Height = Msg.Height + Msg.AttachWin.Height
' End If
End If
Else
If Msg.AttachWin.Visible Then
Msg.AttachWin.Visible = False
Call SizeMessageWindow(Msg)
' If Msg.WindowState = 0 Then
' Msg.Height = Msg.Height - Msg.AttachWin.Height
' End If
End If
End If
Msg.Refresh
End Sub
Sub CopyNamestoMsgBuffer(Msg As Form, fResolveNames As Integer)
Call KillRecips(VBMail.MapiMess)
Call SetRCList(Msg.TxtTo, VBMail.MapiMess, vbRecipTypeTo, fResolveNames)
Call SetRCList(Msg.txtCC, VBMail.MapiMess, vbRecipTypeCc, fResolveNames)
End Sub
Function DateFromMapiDate$(ByVal S$, wFormat%)
' This procedure formats a MAPI date in one of
' two formats for viewing the message.
Y$ = Left$(S$, 4)
M$ = Mid$(S$, 6, 2)
D$ = Mid$(S$, 9, 2)
T$ = Mid$(S$, 12)
Ds# = DateValue(M$ + "/" + D$ + "/" + Y$) + TimeValue(T$)
Select Case wFormat
Case conMailLongDate
f$ = "dddd, mmmm d, yyyy, h:mmAM/PM"
Case conMailListView
f$ = "mm/dd/yy hh:mm"
End Select
DateFromMapiDate = Format$(Ds#, f$)
End Function
Sub DeleteMessage()
' If the currently active form is a message, set MListIndex to
' the correct value.
If TypeOf Screen.ActiveForm Is MsgView Then
MailLst.MList.ListIndex = Val(Screen.ActiveForm.Tag)
ViewingMsg = True
End If
' Delete the mail message.
If MailLst.MList.ListIndex <> -1 Then
VBMail.MapiMess.MsgIndex = MailLst.MList.ListIndex
VBMail.MapiMess.Action = vbMessageDelete
X% = MailLst.MList.ListIndex
MailLst.MList.RemoveItem X%
If X% < MailLst.MList.ListCount - 1 Then
MailLst.MList.ListIndex = X%
Else
MailLst.MList.ListIndex = MailLst.MList.ListCount - 1
End If
VBMail.MsgCountLbl = Format$(VBMail.MapiMess.MsgCount) + " Messages"
' Adjust the index values for currently viewed messages.
If ViewingMsg Then
Screen.ActiveForm.Tag = Str$(-1)
End If