Sending emails to a table - do it from Access or outlook?

K

Kent Dean

Hi Jesper

In a module add a reference to Microsoft CDO
(Collaborative Data) Objects and then paste the following
function.

This function can be attached to a button on a form, or
encapsulated in a recordset loop.

The message format is HTML, so you will need to add some
appropriate tags to your message text so that it formats
correctly.


Public Function SendEmail(ByVal Recipient As String, ByVal
Sender As String, Optional Cc As String, Optional Bcc As
String, Optional Subject As String, Optional Body As
String) As String

Dim objMessage As CDONTS.NewMail
Set objMessage = New CDONTS.NewMail

With objMessage
.BodyFormat = 0
.MailFormat = 0
.To = Recipient
.From = Sender
If Cc <> "" Then .Cc = Cc
If Bcc <> "" Then .Bcc = Bcc
If Subject <> "" Then .Subject = Subject
If Body <> "" Then .Body = Body
.Send
End With

Set objMessage = Nothing

End Function

I hope this helps.

Kind regards
Kent
 

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