Question Auto Email Problem

MOTOWN44

Registered User.
Local time
Today, 05:55
Joined
Aug 18, 2009
Messages
42
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?

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
 
Code:
"<br /><br /><a href='FilePath'>Text</a>" & _
"<br /><br /><b>TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT </b>"[B]& _
[/B]"<br /><br /><b>TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT </b> " & _

Looks like your second line here is missing a space after the ampersand, mayby that helps

JR
 
unfortunatly that hasnt fixed it im still getting "false" in the messge body

altho the compile error seems to have disapeared
 
unfortunatly that hasnt fixed it im still getting "false" in the messge body

altho the compile error seems to have disapeared

Just a guess, but change from a HTML email to a normal email. Does that work?

Have you got word turned on as the editor for emails?
 
Also, your last line of dummy text still has a line continuation syntax
"<br /><br /><b>TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT </b> " & _

I don't think you intended that.

It will append the next line to the body and result in the error.
 

Users who are viewing this thread

Back
Top Bottom