Microsoft Office Tutorials and References
In Depth Information
No Need to Resolve?
You do not need to resolve a recipient if you specified the actual email address when you added
the recipient to the message’s Recipients collection.
When you use this approach, the recipient must be resolved before you can send the message. This
procedure looks through the Outlook address book for the specified display name. If it is found,
the corresponding email address is added to the recipient and you can send the message. If a
message has one or more unresolved recipients, trying to send it will cause an error.
To resolve a recipient, call the Resolve() method. The method returns True if the resolution was
successful, False if not. Here’s an example:
Dim recip As Outlook.Recipient
Set recip = msg.Recipients.Add(“Jane Austin”)
If recip.Resolve Then
‘ Resolved OK - safe to send.
Else
‘ Resolution failed - take steps to correct.
End If
Adding Attachments to a Message
When you are writing VBA code to create email messages, you can add attachments to each
message as desired. You use the Attachments collection’s Add() method, which has the following
syntax:
MailItem.Attachments.Add( Source , Type , Position , DisplayName )
n Source is a required argument specifying the path and name of the file to attach.
n Type is an optional argument specifying the type of the attachment: olByValue
(for an attached file) or olByReference for a link (shortcut) to a file. The default is
olByValue .
n Position is an optional argument specifying the position of the attachment in the
message. The default is for attachments to be placed at the end of the message.
n DisplayName is an optional argument giving the attachment’s display name. If this
argument is omitted, the name of the file will be used as the display name.
It is recommended to save a message before adding or removing attachments. Here’s a code
example that attaches two file attachments to a message:
Search JabSto ::




Custom Search