Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Attach an Access Report to email using .attachments.add without saving to drive first

Status
Not open for further replies.

Johnnycat1

Programmer
May 4, 2005
71
US
Hello...

I am trying to add an access report to an email using the .attachments.add method but I would prefer to not save the attachment outside of access. I am getting the "Object variable or With Block Variable not set" error.

Any help is greatly appreciated.

My code is currently:
Code:
 Private Sub EmailLetterBtn_Click()
On Error GoTo Err_EmailBtn_Click
'References Microsoft Outlook 15.0 Object Library
 
 Dim strAttach As AccessObject
 Dim MyApp As New Outlook.Application
 Dim MyItem As Outlook.MailItem
 Set MyItem = MyApp.CreateItem(olMailItem)
 strAttach = "Letter Select Rpt"
 
 With MyItem
    
    .Subject = Project_Name & " " & Subject
    .ReadReceiptRequested = True
    .HTMLBody = Letter_Text
    .Attachments.Add (strAttach)
End With
MyItem.Display


nanos gigantum humeris insidentes

A dwarf on the shoulders of giants...
 
I would prefer to not save the attachment outside of access.
If you find a solution tell us, but AFAIK it is not possible

using the .attachments.add
The attachments.add of outlook requires a source

The source of the attachment. This can be a file (represented by the full file system path with a file name) or an Outlook item that constitutes the attachment.
Not sure what this is "Letter Select Rpt" but does not look like a full file path to me.

I have demonstrated this multiple times.
1) Save the attachment to a temp folder
2) attach to outlook
3) delete file from disk
I have never seen an example of doing this without first saving to disk.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top