diarmaidbrown
New member
- Local time
- Today, 07:17
- Joined
- Jul 8, 2011
- Messages
- 8
Hi all first time poster and complete novice at access i have got some code from the internet to send email automatically using access and outlook, after the user inputs email add, subject and main body of message three txt attachments (ski, Directions and Partymenu) are added when they hit send email, i was wonder if it would be possible to have 3 check boxes on the form so the user could select to send 1,2,3 or 0 of the attachments.
The code im using is as follows any help would be much appreciated,
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 = olFormatRichText
.To = Me.Email_Address
.Subject = Me.Mess_Subject
.HTMLBody = Me.Mess_Text
.Attachments.Add "C:\Users\Diarmaid\Documents\ski.txt"
.Attachments.Add "C:\Users\Diarmaid\Documents\directions.txt"
.Attachments.Add "C:\Users\Diarmaid\Documents\partymenu.txt"
.Send
End With
Exit Sub
email_error:
MsgBox "An error was encountered." & vbCrLf & "The error message is: " & Err.Description
Resume Error_out
Error_out:
End Sub
The code im using is as follows any help would be much appreciated,
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 = olFormatRichText
.To = Me.Email_Address
.Subject = Me.Mess_Subject
.HTMLBody = Me.Mess_Text
.Attachments.Add "C:\Users\Diarmaid\Documents\ski.txt"
.Attachments.Add "C:\Users\Diarmaid\Documents\directions.txt"
.Attachments.Add "C:\Users\Diarmaid\Documents\partymenu.txt"
.Send
End With
Exit Sub
email_error:
MsgBox "An error was encountered." & vbCrLf & "The error message is: " & Err.Description
Resume Error_out
Error_out:
End Sub