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

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
 
S

Sue Mosher [MVP]

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top