Good Morning
Im having problems automatically sending an email from access
I have the following code to send the email, other than the body text the code I a direct cut and paste of a collegues code and his works but mine doesn’t
Were both at a bit of a loss as to why?
I have all the relevant references in VBA set as it sends my colleagues email fine when I use his unedited code
All that happens is that I either get an email with the subject in but the body merely says “false” or the VBA editor gives the Compile Error: Expected statement or end statement etc error after every line in the code that specifies the body text
Any pointers would be a great help
Thanks
Im having problems automatically sending an email from access
I have the following code to send the email, other than the body text the code I a direct cut and paste of a collegues code and his works but mine doesn’t
Were both at a bit of a loss as to why?
Code:
Public Sub SendEmail()
On Error GoTo Err_Submit
Dim appOutLook As Outlook.Application
Dim MailOutLook As Outlook.MailItem
Set appOutLook = CreateObject("Outlook.Application")
Set MailOutLook = appOutLook.CreateItem(olMailItem)
With MailOutLook
.To = "EMAIL HERE"
.Subject = "AUTO SEND:"
.BodyFormat = olFormatHTML
.HTMLBody = "Usual Update Please" & _
"<br /><br /><a href='FilePath'>Text</a>" & _
"<br /><br /><b>TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT </b>"&_
"<br /><br /><b>TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT </b> " & _
"<br /><br /><b>TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT </b> " & _
"<br /><br /><b>TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT </b> " & _
.DeleteAfterSubmit = True
'.Send
.Display
End With
Set MailOutLook = Nothing
Set appOutLook = Nothing
Exit_Submit:
Exit Sub
[SIZE=3][FONT=Times New Roman]Err_Submit:[/FONT][/SIZE]
[SIZE=3][FONT=Times New Roman]If Err.Number = 287 Then[/FONT][/SIZE]
[SIZE=3][FONT=Times New Roman]MsgBox "Email not sent"[/FONT][/SIZE]
[SIZE=3][FONT=Times New Roman]Else[/FONT][/SIZE]
[SIZE=3][FONT=Times New Roman]MsgBox Err.Number & " " & Err.Description[/FONT][/SIZE]
[SIZE=3][FONT=Times New Roman]Resume Exit_Submit[/FONT][/SIZE]
[SIZE=3][FONT=Times New Roman]End If[/FONT][/SIZE]
[FONT=Times New Roman][SIZE=3]End Sub [/SIZE][/FONT]
I have all the relevant references in VBA set as it sends my colleagues email fine when I use his unedited code
All that happens is that I either get an email with the subject in but the body merely says “false” or the VBA editor gives the Compile Error: Expected statement or end statement etc error after every line in the code that specifies the body text
Any pointers would be a great help
Thanks