Re: VBA - Sending Multiple Attachments to Outlook message
- From: lgray <lindabgray@xxxxxxxxxxx>
- Date: Wed, 16 Jul 2008 11:48:07 -0700
Any ideas on this.....
The next Error message is: "Operation is not supported for this type of
object" and Highlights the following line:
newMail.Attachments.Add rs.Fields("FullPathToFile"), olByValue, 1, "Test Doc"
of the following Code:
Sub createOutlookMailItem()
Dim EmailCode As Database
Dim rs As Recordset
Dim objOutlook As Outlook.Application
Dim newMail As MailItem
Set objOutlook = CreateObject("Outlook.application")
Set newMail = objOutlook.CreateItem(olMailItem)
Set EmailCode = CurrentDb
Set rs = EmailCode.OpenRecordset("Encroachment_Attachments")
newMail.To = "lindabGray@xxxxxxxxxxx"
newMail.Subject = "Encroachment Documents"
While Not rs.EOF
newMail.Attachments.Add rs.Fields("FullPathToFile"), olByValue, 1, "Test
Doc"
Wend
newMail.Display
Set newMailAttachments = Nothing
Set newMail = Nothing
Set objOutlook = Nothing
End Sub
--
Linda
"pietlinden@xxxxxxxxxxx" wrote:
On Jul 15, 3:43 pm, lgray <lindabg...@xxxxxxxxxxx> wrote:.
Is there anybody out there that can go through this simple code and see what'this is redundant... just use newMail.Attachments.Add(strFile)
I've done wrong? I'm still novice, trying to do something new... I'm trying
to go through a recordset to attach files; where a table holds the path to
the attachment. The outlook attachment part of the code works when I hard
code the path into the script, but when I implement the recordset I get an
error that reads...
"Run-time error '-2147467259 (80004005)'
Can't create file: Test1.doc. Right-click the folder you want to create the
file in, and then click Properties on the shortcut menu to check your
permissions for the folder."
Where "Test1.doc" is the name of the file in the table. The table has a
field that holds the file path and the name of the document (again,
Test1.doc, in this example)
The code is below:
Sub createOutlookMailItem()
Dim EmailCode As Database
Dim rs As Recordset
Dim objOutlook As Outlook.Application
Dim newMail As MailItem
Set objOutlook = CreateObject("Outlook.application")
Set newMail = objOutlook.CreateItem(olMailItem)
Set newMailAttachments = newMail.Attachments
Set EmailCode = CurrentDb
Set rs = EmailCode.OpenRecordset("Encroachment_Attachments")
THE NEXT LINE IS WRONG.
' File1 = rs("FullPathToFile")
newMail.To = "lindabg...@xxxxxxxxxxx"'--THIS DOES NOT MAKE SENSE EITHER
newMail.Subject = "Encroachment Documents"
While Not rs.EOF
' newMailAttachments.Add File1, olByValue, 1, "Test Doc"
'--DO THIS INSTEAD
newMail.Attachments.Add rs.Fields("FullPathToFile),
olByValue, 1, "Test Doc"
Wend' newMail.Display '---should be last line in your code.
newMail.Subject = "Documents Confirmation"
newMail.OriginatorDeliveryReportRequested = True
newMail.ReadReceiptRequested = True
'either put .Display here or .SEND
newMail.Send
Set newMailAttachments = Nothing
Set newMail = Nothing
Set objOutlook = Nothing
End Sub
--
Linda
- References:
- VBA - Sending Multiple Attachments to Outlook message
- From: lgray
- Re: VBA - Sending Multiple Attachments to Outlook message
- From: pietlinden@xxxxxxxxxxx
- VBA - Sending Multiple Attachments to Outlook message
- Prev by Date: run-time error 3075 - help
- Next by Date: Re: Automated File Creation
- Previous by thread: Re: VBA - Sending Multiple Attachments to Outlook message
- Next by thread: Re: Find the definition of code in Access 2003
- Index(es):
Relevant Pages
|