Hi,
I would like to send an Email via a button on my form.
I found a nice piece of code on this forum but.... when I try to compile the source it produces an error: "..... datatype is not defined"
This is de code I used:
Do I have to change some settings in my DB?
thx
I would like to send an Email via a button on my form.
I found a nice piece of code on this forum but.... when I try to compile the source it produces an error: "..... datatype is not defined"
This is de code I used:
Code:
Private Sub cmdSendEmail_Click()
On Error GoTo Error_Handler
Dim objOutlook As Outlook.Application
Dim objMsg As Outlook.MailItem
Dim objRecipient As Outlook.Recipient
Dim objMailAttachment As Outlook.Attachment
Dim Attach1 As String
Dim Attach2 As String
Dim Attach3 As String
Dim Attach4 As String
Dim Rec As String
Dim Subj As String
Dim Main As String
Set objOutlook = CreateObject("Outlook.Application")
Set objMsg = objOutlook.CreateItem(olMailItem)
Attach1 = ""
Attach2 = ""
Attach3 = ""
Attach4 = ""
With objMsg
.To = "r.cutts@tees.ac.uk"
.Subject = "subject of e-mail"
.Body = "body goes here"
If Attach1 <> "" Then
Set objMailAttachment = .Attachments.Add(Attach1)
End If
If Attach2 <> "" Then
Set objMailAttachment = .Attachments.Add(Attach2)
End If
If Attach3 <> "" Then
Set objMailAttachment = .Attachments.Add(Attach3)
End If
If Attach4 <> "" Then
Set objMailAttachment = .Attachments.Add(Attach4)
End If
.send
End With
Set objOutlook = Nothing
Set objMsg = Nothing
Set objRecipient = Nothing
Set objMailAttachment = Nothing
Error_Handler:
If Err.Number = "287" Then
MsgBox "You clicked No to the Outlook security warning. " & _
"Rerun the procedure and click Yes to access e-mail" & _
"addresses to send your message. "
End If
'DoCmd.SetWarnings False
'DoCmd.SendObject , "", "", Form_VestigingenForm.txtEmail_ContactPersonen, "", "", "", "", False, ""
'DoCmd.SetWarnings True
End Function
Do I have to change some settings in my DB?
thx