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
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