Banderas23
Registered User.
- Local time
- Today, 08:46
- Joined
- Nov 12, 2015
- Messages
- 23
I have some code that creates an outlook email and populates the message to field and aubject field as I need.
When it comes to the body I cannot get it to format how I need. I've tried various command I have read online and it just doesn't seem to work.
Can anyone help fill out the missing code please:
The form has numerous fields and at the end of entering a form I want to click send and it email a copy of some of the fields. I'm struggling with the formatting.
Private Sub Command219_Click()
Dim oOutlook As Outlook.Application
Dim oEmailItem As MailItem
' prevent 429 error, if outlook not open
On Error Resume Next
Err.Clear
Set oOutlook = GetObject(, "Outlook.application")
If Err.number <> 0 Then
Set oOutlook = New Outlook.Application
End If
Set oEmailItem = oOutlook.CreateItem(olMailItem)
With oEmailItem
If IsNull(Me.Email) Then
MsgBox "This customer has no email address."
Else
.To = Me.Email
.Subject = "Email Confirmation: " & Me.Reference_nu
.Body = "Dear " & Me.CustomerName
.Display
End If
End With
Set oEmailItem = Nothing
Set oOutlook = nothign
End Sub
I want the .body to read like this:-
Dear customer name
This is your email confirmation for order number reference_nu on date Date costing a total of Price
Reference, date and price being fields in the form.
I'm struggling getting the carriages between dear customer and the next line of text!
Any help would be much appreciated
Using access2013
Thanks
Antony
When it comes to the body I cannot get it to format how I need. I've tried various command I have read online and it just doesn't seem to work.
Can anyone help fill out the missing code please:
The form has numerous fields and at the end of entering a form I want to click send and it email a copy of some of the fields. I'm struggling with the formatting.
Private Sub Command219_Click()
Dim oOutlook As Outlook.Application
Dim oEmailItem As MailItem
' prevent 429 error, if outlook not open
On Error Resume Next
Err.Clear
Set oOutlook = GetObject(, "Outlook.application")
If Err.number <> 0 Then
Set oOutlook = New Outlook.Application
End If
Set oEmailItem = oOutlook.CreateItem(olMailItem)
With oEmailItem
If IsNull(Me.Email) Then
MsgBox "This customer has no email address."
Else
.To = Me.Email
.Subject = "Email Confirmation: " & Me.Reference_nu
.Body = "Dear " & Me.CustomerName
.Display
End If
End With
Set oEmailItem = Nothing
Set oOutlook = nothign
End Sub
I want the .body to read like this:-
Dear customer name
This is your email confirmation for order number reference_nu on date Date costing a total of Price
Reference, date and price being fields in the form.
I'm struggling getting the carriages between dear customer and the next line of text!
Any help would be much appreciated
Using access2013
Thanks
Antony