Discussion:
How do I add emails as attachments to a new email?
(too old to reply)
McKilty
2011-05-16 15:39:47 UTC
Permalink
I have a routine which loops through a group of emails. If the emails
meet a specific criteria, I want to add them to a new email. I do not
know how to add an email as an attachment.

The following is parts of my code:
'----------------------------------------------------------------------
Set mItemCollection = mItemCollection.Restrict("[SentOn] > '" &
Format(dteStart, "yyyy-mm-dd hh:nn:ss") & "' AND [SentOn] < '" &
Format(dteEnd, "yyyy-mm-dd hh:nn:ss") & "'")

For lMailItem = 1 To mItemCollection.Count
Set myItem = mItemCollection(lMailItem)
Set SafeMail = CreateObject("Redemption.SafeMailItem")
SafeMail.Item = myItem

'If Criteria is true then add attachment
'If email is not already created then
Set objOutlookMsg = Outlook.CreateItem(olMailItem)
'Set recipients, subject, body

'else if email is already created
objOutlookMsg.Attachments.Add SafeMail.item
'----------------------------------------------------------------------

This does not work, but I really didn't expect it to. How do I attach
the emails to this new email?
McKilty
2011-05-16 20:14:36 UTC
Permalink
I saw this post...

http://www.pcreview.co.uk/forums/send-existing-email-attachment-using-vba-t3726344.html

...and now I think maybe my code as written should work. However, it
doesn't. I tried many different ways to write this:


objOutlookMsg.Attachments.Add (SafeMail.Item) 'Runtime error
-2146697203. The operation failed.
objOutlookMsg.Attachments.Add SafeMail.Item 'Runtime error 438.
Object doesn't support this property or method
objOutlookMsg.Attachments.Add (myItem) 'Runtime error 438. Object
doesn't support this property or method
objOutlookMsg.Attachments.Add (mItemCollection(lMailItem)) 'Runtime
error 438. Object doesn't support this property or method
objOutlookMsg.Attachments.Add
(objOutlookMsg.Attachments.Add(mItemCollection(lMailItem).Item))
'Runtime error 438. Object doesn't support this property or method
McKilty
2011-05-16 20:29:38 UTC
Permalink
I saw this post...

http://www.pcreview.co.uk/forums/send-existing-email-attachment-using...


...and now I think maybe my code as written should work. However, it
doesn't. I tried many different ways to write this:

'Runtime error -2146697203.
The operation failed.
----------------------------------------------------------------------
objOutlookMsg.Attachments.Add (SafeMail.Item)

'Runtime error 438.
Object doesn't support this property or method
----------------------------------------------------------------------
objOutlookMsg.Attachments.Add
objOutlookMsg.Attachments.Add(SafeMail.Item, olEmbeddeditem)

objOutlookMsg.Attachments.Add SafeMail.Item

objOutlookMsg.Attachments.Add (myItem)

objOutlookMsg.Attachments.Add (mItemCollection(lMailItem))

objOutlookMsg.Attachments.Add
(objOutlookMsg.Attachments.Add(mItemCollection(lMailItem).Item))

Loading...