RobertIngles
Technical User
Hi guys - I sourced a send email form and code from BlueClaw on the net. I have had real problems getting the emails to send - it seems hit and miss - a couple times it worked perfectly but now it is saying there is an error in my code - .Send is highlighted when I go to the debugging screen. Can someone tell me what the heck I am doing wrong?
Private Sub Command20_Click()
Dim mess_body As String
Dim appOutLook As Outlook.Application
Dim MailOutLook As Outlook.MailItem
Set appOutLook = CreateObject("Outlook.Application")
Set MailOutLook = appOutLook.CreateItem(olMailItem)
Set appOutLook = CreateObject("Outlook.Application")
Set MailOutLook = appOutLook.CreateItem(olMailItem)
With MailOutLook
.BodyFormat = olFormatHTML
.HTMLBody = "<HTML><H2>"
.To = Me.Email_Address
.Subject = Me.Mess_Subject
.HTMLBody = Me.mess_text
If Left(Me.Mail_Attachment_Path, 1) <> "<" Then
.Attachments.Add (Me.Mail_Attachment_Path)
.Send
End If
'.DeleteAfterSubmit = True 'This would let Outlook send the note without storing it in your sent bin
DoCmd.GoToRecord , , acNext
End With
'MsgBox MailOutLook.Body
Exit Sub
email_error:
MsgBox "An error was encountered." & vbCrLf & "The error message is: " & Err.Description
Resume Error_out
Error_out:
End Sub
Private Sub Command20_Click()
Dim mess_body As String
Dim appOutLook As Outlook.Application
Dim MailOutLook As Outlook.MailItem
Set appOutLook = CreateObject("Outlook.Application")
Set MailOutLook = appOutLook.CreateItem(olMailItem)
Set appOutLook = CreateObject("Outlook.Application")
Set MailOutLook = appOutLook.CreateItem(olMailItem)
With MailOutLook
.BodyFormat = olFormatHTML
.HTMLBody = "<HTML><H2>"
.To = Me.Email_Address
.Subject = Me.Mess_Subject
.HTMLBody = Me.mess_text
If Left(Me.Mail_Attachment_Path, 1) <> "<" Then
.Attachments.Add (Me.Mail_Attachment_Path)
.Send
End If
'.DeleteAfterSubmit = True 'This would let Outlook send the note without storing it in your sent bin
DoCmd.GoToRecord , , acNext
End With
'MsgBox MailOutLook.Body
Exit Sub
email_error:
MsgBox "An error was encountered." & vbCrLf & "The error message is: " & Err.Description
Resume Error_out
Error_out:
End Sub