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 derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Send Multiple Objects (i.e., Reports, Tables) through Access

Status
Not open for further replies.

kmkland

Technical User
Dec 15, 2004
114
US
I am trying to send multiple objects (i.e., Reports and Tables) through Access to Outlook using SendObject, but this only gives me one attachment per email. I want to be able to send multiple attachments for each email that I send. I do not even know where to begin with this. I am learning VB at the moment, so I would be willing to experiment with any scripts.
Thanks in advance.
Kim
 
I'm not sure if there is a way. Of course, I really haven't had great need for it. Usually I put all my reports, as subreports, in one if I need to do this.
 
You can just use multiple .attachment objects in your code like this.

Code:
Function openoutlook()
Dim myOLItem As Outlook.MailItem
Dim strMessage As String

strMessage = "Hello multiple attachments"

Set myOLApp = CreateObject("Outlook.Application")
Set myOLItem = myOLApp.CreateItem(olMailItem)
   myOLItem.To = "somebody@someplace.com"
   myOLItem.Body = strMessage
   myOLItem.Subject = "Multiple Attachments"
      
[b]Set objOutlookAttach = myOLItem.Attachments.Add("C:\My Documents\Assignments.doc")
Set objOutlookAttach = myOLItem.Attachments.Add("C:\My Documents\B2295d.doc")[/b]
   myOLItem.Send

If you want to pass selected items from something like a multiselect list box then you would have to set up a loop and pass the name of the attachment to the .attachments object inside the loop. Post back if you have problems.

Paul
 
Hi Paul,
What I am actually trying to accomplish is sending a table and 2 reports from within Access to Outlook, not import from another location.
Is this possible??
Kind Regards,
Kim
 
I may be wrong, but I don't think you can directly attach a report or table without exporting it to a folder first and saving it in a file format that you can use as an attachment. Like .rtf or .xls among others. Even if you do it manually, using the menu bar, File....SendTo...MailRecipient(as Attachment), you receive a prompt to select the format you want to send the object as.

Paul
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top