Email Access Object Using VBA

G

Guest

Hi,

I want to be able to email an MS Access Table, Query, or Report using VBA
but can't seem to figure out how to do it. All the examples I've seen have
been for emailing a file on the network - I've tested these examples and they
work fine, but I don't want to have to output my Access table/query/report to
the network in order to email it.

Here's the code - the SendEmails function pulls the email address (Eadds)
and Report Name (RptNm) from a table):

Function SendEmails(Eadds As String, RptNm As String)

Dim oOLApp As Outlook.Application
Dim oOLDoc As Outlook.MailItem

Set oOLApp = New Outlook.Application
Set oOLDoc = oOLApp.CreateItem(olMailItem)

With oOLDoc
.To = Eadds
.Subject = "test " & RptNm
.Body = "Test2"
.Attachments.Add ("\\Ihe-apps1\Data\Servicing\ELI\IResults\?")
.Display
End With
End Function

The question mark denotes where I'm getting stuck.

Any help would be much appreciated.

Manuel
 
G

Guest

You're complicating your life for no reason. You do not need to use outlook
to perform such a task. Access has the SendObject method for exactly this
purpose. Look it up in the VBE help.

Also, a good ref about sending email (different technics available) from
access is http://www.granite.ab.ca/access/email.htm
 
G

Guest

Yes, I'm familiar with the SendObject method; however, I didn't want to use
it because it does not allow for multiple attachments. Also, by accessing
Outlook directly I'm able to manipulate a lot of Outlooks properties,
something I'm not able to do with SendObject.

If anyone has any suggestions for my issues, I would really appreciate your
assistance.

Thanks,
Manuel
 

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

Top