mSendEmail
If you have Outlook 98 you can send email using VB! Use this code for the basis of creating mailing programs!
AI
KI-Zusammenfassung: This codebase represents a historical implementation of the logic described in the metadata. Our preservation engine analyzes the structure to provide context for modern developers.
Quellcode
Sub mSendEmail(ByVal vcolEmailAddress As Collection, _
ByVal vstrSubject As String, _
ByVal vstrBody As String)
Dim ol As New Outlook.Application
Dim ns As Outlook.NameSpace
'Return a reference to the MAPI layer
Dim newMail As Outlook.MailItem
'Create a new mail message item
Set ns = ol.GetNamespace("MAPI")
Set newMail = ol.CreateItem(olMailItem)
'set properties
With newMail
'Add the subject of the mail message
.Subject = vstrSubject
'Create some body text
.Body = vstrBody
'**************
'go through all
'addresses passed in
'**************
Dim strEmailAddress As String
Dim intIndex As Integer
For intIndex = 1 To vcolEmailAddress.Count
strEmailAddress = vcolEmailAddress.Item(intIndex)
'Add a recipient and test to make sure that the
'address is valid using the Resolve method
With .Recipients.Add(strEmailAddress)
.Type = olTo
If Not .Resolve Then
'MsgBox "Unable to resolve address.", vbInformation
Debug.Print "Unable to resolve address " & strEmailAddress & "."
'Exit Sub
End If
End With
Next intIndex
' 'Attach a file as a link with an icon
' With .Attachments.Add _
' ("\\Training\training.xls", olByReference)
' .DisplayName = "Training info"
' End With
'Send the mail message
.Send
End With
'Release memory
Set ol = Nothing
Set ns = Nothing
Set newMail = Nothing
End Sub
Originalkommentare (3)
Wiederhergestellt von der Wayback Machine