Outlook Banter

Outlook Banter (http://www.outlookbanter.com/)
-   Outlook and VBA (http://www.outlookbanter.com/outlook-vba/)
-   -   Add Attachment to Item in Outbox (http://www.outlookbanter.com/outlook-vba/32652-add-attachment-item-outbox.html)

Joel November 12th 06 04:49 PM

Add Attachment to Item in Outbox
 
I have following code to add attachment to selected items in outbox. I would
like to add code to test the TO: value and attach a specifice email based on
value.


Sub AddAttachmentToSelectedMessages()
Dim objItem As MailItem
If ActiveExplorer.Selection.Count = 0 Then Exit Sub

For Each objItem In ActiveExplorer.Selection
objItem.Attachments.Add ("C:\ap.xls")
objItem.Save
Next
End Sub

I tried to add line such as:

If objItem.To = " then
objItem.Attachments.Add ("C:\bob.xls") ... but it didn't work.

Any ideas to identify the TO value of teh email in the outbox??

Thanks,

Joel

Michael Bauer [MVP - Outlook] November 13th 06 07:12 AM

Add Attachment to Item in Outbox
 


It's better to read the addresses from each item's Recipients collection
instead.

--
Viele Gruesse / Best regards
Michael Bauer - MVP Outlook
-- www.VBOffice.net --

Am Sun, 12 Nov 2006 07:49:02 -0800 schrieb Joel:

I have following code to add attachment to selected items in outbox. I

would
like to add code to test the TO: value and attach a specifice email based

on
value.


Sub AddAttachmentToSelectedMessages()
Dim objItem As MailItem
If ActiveExplorer.Selection.Count = 0 Then Exit Sub

For Each objItem In ActiveExplorer.Selection
objItem.Attachments.Add ("C:\ap.xls")
objItem.Save
Next
End Sub

I tried to add line such as:

If objItem.To = " then
objItem.Attachments.Add ("C:\bob.xls") ... but it didn't work.

Any ideas to identify the TO value of teh email in the outbox??

Thanks,

Joel



All times are GMT +1. The time now is 09:26 AM.

Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 2.4.0
Copyright ©2004-2006 OutlookBanter.com