Hi!
I want to make a button on my form which opens Outlook and places certain e-mail adresses at the right places. I have a small problem though. My current code is as follows:
Private Sub EmailButton_Click()
Dim strToWhom As String
Dim strToCCWhom As String
Dim strMsgBody As String
Dim strSubject As String
strSubject = "Your Subject goes here!"
strToWhom = Me.Emailadres
strToCCWhom = Me.Emaildres2
strMsgBody = "Your Body text goes here!"
DoCmd.SendObject , , , strToWhom, strToCCWhom, , strSubject, strMsgBody, True
End Sub
' Emailadres' and 'Emailadres2' are the names of the text boxes in which the adresses are.
When I click on the EmailButton Outlook pops-up and displays the right adresses, subject and so on at the right place.
However, if I do not send an email and when I closes Outlook, I get a run-time error.
I think I have to put something extra in the code, but I am not really sure what to put in it. Anyone a suggestion?
Cheers,
Willem
I want to make a button on my form which opens Outlook and places certain e-mail adresses at the right places. I have a small problem though. My current code is as follows:
Private Sub EmailButton_Click()
Dim strToWhom As String
Dim strToCCWhom As String
Dim strMsgBody As String
Dim strSubject As String
strSubject = "Your Subject goes here!"
strToWhom = Me.Emailadres
strToCCWhom = Me.Emaildres2
strMsgBody = "Your Body text goes here!"
DoCmd.SendObject , , , strToWhom, strToCCWhom, , strSubject, strMsgBody, True
End Sub
' Emailadres' and 'Emailadres2' are the names of the text boxes in which the adresses are.
When I click on the EmailButton Outlook pops-up and displays the right adresses, subject and so on at the right place.
However, if I do not send an email and when I closes Outlook, I get a run-time error.
I think I have to put something extra in the code, but I am not really sure what to put in it. Anyone a suggestion?
Cheers,
Willem