M
Mike
I'm using the following code for a button on a form to
send an e-mail message:
PrivateSub Button_Click()
Dim olookApp As Outlook.Application
Dim olookMsg As Outlook.MailItem
Dim olookRecipient As Outlook.Recipient
' create the Outlook session.
Set olookApp = CreateObject("Outlook.Application")
' create the message.
Set olookMsg = olookApp.CreateItem(olMailItem)
With olookMsg
' add the To recipient(s) to the message.
Set olookRecipient = .Recipients.Add
("(e-mail address removed); (e-mail address removed)")
olookRecipient.Type = olTo
' set the Subject, Body, and Importance of the
message.
.Subject = "This is an Automation test with
Microsoft Outlook"
.Body = "Last test" & vbCrLf & vbCrLf
.Importance = olImportanceHigh 'High importance
' resolve each Recipient's name
For Each olookRecipient In .Recipients
olookRecipient.Resolve
If Not olookRecipient.Resolve Then
olookMsg.Display ' display any names that
can't be resolved
End If
Next
.Send
End With
Set olookMsg = Nothing
Set olookApp = Nothing
End Sub
The code works, but the message is delivered only to the
last address in the list. The rest messages are returned
claiming on the address syntax error.
I tried to put comma instead of ";" between the addresses
in the list but in vain.
What is the problem I wonder?
Thanks for help!
send an e-mail message:
PrivateSub Button_Click()
Dim olookApp As Outlook.Application
Dim olookMsg As Outlook.MailItem
Dim olookRecipient As Outlook.Recipient
' create the Outlook session.
Set olookApp = CreateObject("Outlook.Application")
' create the message.
Set olookMsg = olookApp.CreateItem(olMailItem)
With olookMsg
' add the To recipient(s) to the message.
Set olookRecipient = .Recipients.Add
("(e-mail address removed); (e-mail address removed)")
olookRecipient.Type = olTo
' set the Subject, Body, and Importance of the
message.
.Subject = "This is an Automation test with
Microsoft Outlook"
.Body = "Last test" & vbCrLf & vbCrLf
.Importance = olImportanceHigh 'High importance
' resolve each Recipient's name
For Each olookRecipient In .Recipients
olookRecipient.Resolve
If Not olookRecipient.Resolve Then
olookMsg.Display ' display any names that
can't be resolved
End If
Next
.Send
End With
Set olookMsg = Nothing
Set olookApp = Nothing
End Sub
The code works, but the message is delivered only to the
last address in the list. The rest messages are returned
claiming on the address syntax error.
I tried to put comma instead of ";" between the addresses
in the list but in vain.
What is the problem I wonder?
Thanks for help!