Euro5
asked on
VBA sending mail to multiple recipients
I have a code that is working well but I can't figure out how to send to multiple ToAddress
I tried the following, but just get an error.
This works for only one recipient:
I tried the following, but just get an error.
ToAddress = "firstemail@gmail.com;secondemail@gmail.com"
This works for only one recipient:
Const PR_ATTACH_MIME_TAG = "http://schemas.microsoft.com/mapi/proptag/0x370E001E"
Const PR_ATTACH_CONTENT_ID = "http://schemas.microsoft.com/mapi/proptag/0x3712001E"
Const PR_ATTACHMENT_HIDDEN = "http://schemas.microsoft.com/mapi/proptag/0x7FFE000B"
Sub testing2()
Dim ToAddress
Dim FromAddress
Dim MessageSubject
Dim MyTime
Dim MessageBody
Dim MessageAttachment
Dim ol, ns, newMail
Dim realAttachment
MyTime = Now
ToAddress = "firstemail@gmail.com"
MessageSubject = "Auto Stats " & MyTime
MessageBody = "Good Morning" & vbCrLf & "Produced at " & MyTime
MessageAttachment = "D:\1.png"
Set ns = Outlook.GetNamespace("MAPI")
Set newMail = Outlook.CreateItem(olMailItem)
newMail.Subject = MessageSubject
newMail.Body = MessageBody
newMail.Recipients.Add (ToAddress)
Set realAttachment = newMail.Attachments.Add(MessageAttachment)
Set oPA = realAttachment.PropertyAccessor
oPA.SetProperty PR_ATTACH_MIME_TAG, "image/png"
oPA.SetProperty PR_ATTACH_CONTENT_ID, "myident" 'change myident for another other image
newMail.HTMLBody = newMail.HTMLBody & "<IMG align=baseline border=0 hspace=0 src=cid:myident>" 'need to match the "myident" above
newMail.Send
End Sub
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Open in new window