A Microsoft Outlook email forum. Outlook Banter

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » Outlook Banter forum » Microsoft Outlook Email Newsgroups » Outlook and VBA
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

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



 
 
Thread Tools Search this Thread Display Modes
  #1  
Old August 2nd 06, 05:37 PM posted to microsoft.public.outlook.program_vba
[email protected]
external usenet poster
 
Posts: 1
Default Help - can't add "Item" (of type MailItem) using Attachments.Add()

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).It ems

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 = "
myEmail.Subject = "FYI"
' attaching the file
myEmail.Attachments.Add (Item)
' now send the message
myEmail.Send

End If

End Sub

  #2  
Old August 3rd 06, 06:55 AM posted to microsoft.public.outlook.program_vba
Michael Bauer [MVP - Outlook]
external usenet poster
 
Posts: 1,885
Default Help - can't add "Item" (of type MailItem) using Attachments.Add()

Am 2 Aug 2006 08:37:58 -0700 schrieb :

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

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


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).It ems

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 = "
myEmail.Subject = "FYI"
' attaching the file
myEmail.Attachments.Add (Item)
' now send the message
myEmail.Send

End If

End Sub

 




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
How do I add or delete an addressee in the "To" and "CC" boxes? bkaras Outlook - Installation 1 July 30th 06 04:51 AM
How do I add or delete an addressee in the "To" and "CC" boxes? bkaras Outlook - Installation 0 July 29th 06 07:51 PM
I do not have "Encoding" item in my "View" menu of Outlook 2003? Baher Outlook - Installation 0 June 20th 06 10:35 AM
How to add new "addresses" deafaults e.g. "Mr. and Mrs." H. Christinger Outlook - Using Contacts 1 May 26th 06 10:35 AM
How do I change or add an "Entry Types" in journal entrys MGS Outlook - General Queries 2 January 22nd 06 01:14 AM


All times are GMT +1. The time now is 11:18 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-2025 Outlook Banter.
The comments are property of their posters.