Help - can't add "Item" (of type MailItem) using Attachments.Add()

Z

zssachen

Hello,

Any suggestions on why I get a "Run Time Error '-1407020020
(a838838833)': Can't find this file. Make sure the path and file name
are correct." in the code below?

Public Sub Application_Startup()

' Reference the items in the Inbox. Because myOlItems is declared
' "WithEvents" the ItemAdd event will fire below.
Set myOlItems =
Outlook.Session.GetDefaultFolder(olFolderInbox).Items

End Sub

Private Sub myOlItems_ItemAdd(ByVal Item As Object)

' Check to make sure it is an Outlook mail message, otherwise
' subsequent code will probably fail depending on what type
' of item it is.
If TypeName(Item) = "MailItem" Then

Dim mailToFwd As MailItem
Set mailToFwd = Item
'create a new message and address it
Dim myEmail As MailItem
Set myEmail = Application.CreateItem(olMailItem)
myEmail.To = "(e-mail address removed)"
myEmail.Subject = "FYI"
' attaching the file
myEmail.Attachments.Add (Item)
' now send the message
myEmail.Send

End If

End Sub
 
M

Michael Bauer [MVP - Outlook]

Am 2 Aug 2006 08:37:58 -0700 schrieb (e-mail address removed):

If you do not need the function result, i.e. the ref onto the added
attachment, then don´t write the brackets, but:

myEmail.Attachments.Add Item
 

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