VBA Macro in Outlook - Run-time Error '13'

  • Thread starter Thread starter saabi
  • Start date Start date
S

saabi

I have a simple macro(pasted below), trying to attach a
calendar item to emails sent (mail merge doesn't allow me
to embed a calendar invite directly). I get a 'Type
Mismatch' error. The error is thrown at the 'For' loop
statement. Any help would be much appreciated.

Thanks

Sub AddAttachments()
Dim myOutbox As MAPIFolder
Set myOutbox = Application.Session.GetDefaultFolder
(olFolderOutbox)
Dim myMailItem As MailItem
For Each myMailItem In myOutbox.Items
myMailItem.Attachments.Add ("Path to my Calendar
file")
myMailItem.Send
Next
End Sub
 
There's no reason to assume that all the items in the Outbox are MailItems. Try Dim myMailItm as Object.

If that doesn't work, tell us what statement produces the error.
--
Sue Mosher, Outlook MVP
Outlook and Exchange solutions at http://www.slipstick.com
Author of
Microsoft Outlook Programming: Jumpstart
for Administrators, Power Users, and Developers
 
Back
Top