B
bifteki via AccessMonster.com
I want to send an email message through Outlook. I've written the following
code.
Public Sub SendContactEmail()
Dim appOutlook As New Outlook.Application
Dim nsOutlook As NameSpace
Dim emailMsg As Outlook.MailItem
Dim sendTo As String
Set nsOutlook = appOutlook.GetNamespace("MAPI")
emailMsg.BodyFormat = olFormatHTML
emailMsg.HTMLBody = "Date:" & fld_contact_date
For Each fld_aniperson_surname In lst_contact_aniperson
emailMsg.Recipients = "SELECT fld_aniperson_id FROM tbl_anipersons
WHERE.value=tbl_anipersons.fld_aniperson_surname"
Next
emailMsg.Send
End Sub
A run-time error #91 occurs on the BodyFormat line, which says: "<Object
variable or With block variable not set>".
It' s clear that I've made a mistake somewhere or maybe the whole approach is
wrong, as I'm not very experienced in Access but I can't find how to do that.
Thanx in advance.
code.
Public Sub SendContactEmail()
Dim appOutlook As New Outlook.Application
Dim nsOutlook As NameSpace
Dim emailMsg As Outlook.MailItem
Dim sendTo As String
Set nsOutlook = appOutlook.GetNamespace("MAPI")
emailMsg.BodyFormat = olFormatHTML
emailMsg.HTMLBody = "Date:" & fld_contact_date
For Each fld_aniperson_surname In lst_contact_aniperson
emailMsg.Recipients = "SELECT fld_aniperson_id FROM tbl_anipersons
WHERE.value=tbl_anipersons.fld_aniperson_surname"
Next
emailMsg.Send
End Sub
A run-time error #91 occurs on the BodyFormat line, which says: "<Object
variable or With block variable not set>".
It' s clear that I've made a mistake somewhere or maybe the whole approach is
wrong, as I'm not very experienced in Access but I can't find how to do that.
Thanx in advance.