RobertIngles
Technical User
Hi all;
I have read through a bunch of posts here and on the web however none seem to fit what I am wanting to do.
I have built an email form that sends emails via outlook (thanks to a sample posting that got me started).
Each email has information pertaining only to the recipient it is addressed to. I have to send out several hundred and am trying to create code for a "Send All Emails" button that can be placed on the form and that, when activated will send all emails to all the records which have been retrieved. I'm not sure if this can be done from the form or if I need to create the button on the switchboard so maybe someone could advise on that. I tried to add a loop statement to the send button but no luck - lack of coding experience vs hit and miss is stalling me.
The currect code associated with my send button is:
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)
End If
'.DeleteAfterSubmit = True
.Send
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
Any help would be appreciated.
I have read through a bunch of posts here and on the web however none seem to fit what I am wanting to do.
I have built an email form that sends emails via outlook (thanks to a sample posting that got me started).
Each email has information pertaining only to the recipient it is addressed to. I have to send out several hundred and am trying to create code for a "Send All Emails" button that can be placed on the form and that, when activated will send all emails to all the records which have been retrieved. I'm not sure if this can be done from the form or if I need to create the button on the switchboard so maybe someone could advise on that. I tried to add a loop statement to the send button but no luck - lack of coding experience vs hit and miss is stalling me.
The currect code associated with my send button is:
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)
End If
'.DeleteAfterSubmit = True
.Send
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
Any help would be appreciated.