Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem With Code to Send Email from Access via Outlook

Status
Not open for further replies.

RobertIngles

Technical User
Jan 20, 2011
113
CA
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

 
Hey don't know if this will be any help to you now that you got it working and all. But i found this small program online called bmail that runs from the command prompt. I used it in access to send emails using shell() meaning that i did not need to use outlook to send mail. Can't remember the website but you could google it.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top