I have probably spent more time trying to figure this out by myself than I should have. I have an access database that we use to process orders. I know how to send emails as an attachment but what we need is to have an HTML email open with specific wording. Below is the code I have entered. Sometimes it sort of works but it opens an email and there is no formatting so the carriage returns are not working. Now I'm getting an error message compile syntax error. Any help would be greatly appreciated.
This is the code...
This is the code...
Rich (BB code):
Sub SendEmail()
Dim oOutlook As Outlook.Application
Dim oEmailItem As MailItem
'Prevent 429 error, if outlook not open
10 On Error Resume Next
20 Err.Clear
30 Set oOutlook = GetObject(, "Outlook.Application")
40 If Err.Number <> 0 Then
50 Set oOutlook = New Outlook.Application
60 End If
70 Set db = CurrentDb()
80 Set recordset = CurrentData
90 Set MailList = db.OpenRecordset("Email_BO_Qry")
100 Set oEmailItem = oOutlook.CreateItem(olMailItem)
110 Set oOutlookMail = HTMLBody
120 With oEmailItem
130 .To =
140 .Subject = "Dani Leather USA - Product Back Order"
150 .BodyFormat = olFormatHTML
160 .HTMLBody = _
170 "Thank you for your recent order. Unfortunately, the following item(s) you've ordered are currently not in stock in the NJ warehouse and on order with the tannery." & vbCrLf & _
180 & vbCrLf & _(Color) & vbCrLf & _
190 "Below are a few suggestions we can offer for the back ordered item." & vbCrLf & _
200 & vbCrLf & _"1. We can place the item on back order and deliver your order as soon as we receive it." & vbCrLf & _
210 "2. If this is a stock item, we can check with the tannery for availablity. If it is available, we can have the leather airshipped directly to you (air freight charges may be applied)."& vbCrLf & _
220 "3. We could present you with an alternate similar color." & vbCrLf & _
230 & vbCrLf & _"If you have any questions or you'd like to make a change to your order, please call us. We appreciate your business, and we apologise for any inconvenience this delay causes you."
240 .Display
250 End With
260 Set oEmailItem = Nothing
270 Set oOutlook = Nothing
End Sub
Private Sub Command7_Click()
10 Call SendEmail
End Sub[/code]
Last edited by a moderator: