Code for Emailing with attachments from Access

  • Thread starter Thread starter jon.ingram
  • Start date Start date
J

jon.ingram

I am wondering if anyone out there has some VB code that I can put in
access that will open outlook email attach 2 excel files and address
it to a distribution list I have saved in outlook.

This would be huge....thanks.
 
Here is an MSDN article that should help you get started. I haven't tried it
out yet, but at first glance it appears to allow only one attached file to be
included as an optional parameter. You should be able to modify this to loop
through a series of attachment paths.

Using Automation in Microsoft Office Access 2003 to Work with Microsoft
Office Outlook 2003
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dno2k3ta/html/odc_ac_olauto.asp


As for accessing a saved distribution list, I'm afraid you are on your own
there. I'm pretty sure this capability has been denied, because it provides
an open path for virus writers to access e-mail addresses via code.


Tom

http://www.access.qbuilt.com/html/expert_contributors.html
http://www.access.qbuilt.com/html/search.html
__________________________________________
 
Here is an example:

Set o = CreateObject("Outlook.Application")
'Set o = CreateObject("Word.Application")
Set m = o.CreateItem(0)

m.To = "Paul Tucker" ' The distribution list name goes here
m.Subject = "SUPP Analysis Spreadsheet "

m.body = Chr(13) & Chr(13) & _
" Date: " & Date & Chr(13) & " " & _
"SharePoint as of: " & ImportedShare & Chr(13) & " " &
_
"Vendor Stat as of: " & ImportedXLS & Chr(13) & " " & _
"Analysis File: " & exportName & Chr(13) & " " & _
"Exported on: " & exportedXLS & Chr(13) & " " &
_
Chr(13) & _
Chr(13)


m.attachments.Add ReportDir & exportName ' point to the full
address of attachment here

'
There can be multiple of the above

' m.display ' display shows email and
the user has to press send button
m.send ' Send does it
automatically with security from Outlook

Ron
 

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

Back
Top