Send Email

rbs

Board Regular
Joined
Oct 6, 2002
Messages
58
Hi Everyone,

I am sending emails from a form based on the contents of fields on the form.

It is working fine, but I need paragraphs to appear in the body.

How do I do this?


My script is as follows:

Private Sub Command149_Click()

Dim strEmail As String
Dim strclient As String
Dim strmessage As String
Dim strsubject As String
Dim strSQL As String

Dim objOutlook As Outlook.Application
Dim objEmail As Outlook.MailItem

Set objOutlook = CreateObject("outlook.application")
Set objEmail = objOutlook.createitem(olmailitem)

strEmail = Me![Email Address]
strmessage = "Re: Purchase Order # : " & Me!Text152 & Me!Text159 & "Kind Regards, " & Me!Text161
strsubject = Me!Text157 & " " & Me!Text152

With objEmail
.to = strEmail
.subject = strsubject
.Body = strmessage
.send
End With

MsgBox "Email Sent", vbInformation, "Notice"

Set objEmail = Nothing
objOutlook.Quit
Set objOutlook = Nothing

End Sub

Thanks in advance.

N.
 

Excel Facts

Do you hate GETPIVOTDATA?
Prevent GETPIVOTDATA. Select inside a PivotTable. In the Analyze tab of the ribbon, open the dropown next to Options and turn it off
Hi,

I'm not an expert at coding, but try inserting this :

& (Chr(13)+Chr(10)+Chr(13)+Chr(10))

into this piece of code :

strmessage = "Re: Purchase Order # : " & Me!Text152 & Me!Text159 & "Kind Regards, " & Me!Text161

so that it looks something like this :

strmessage = "Re: Purchase Order # : " & Me!Text152 & (Chr(13)+Chr(10)+Chr(13)+Chr(10))
& Me!Text159 & (Chr(13)+Chr(10)+Chr(13)+Chr(10))
& "Kind Regards, " & (Chr(13)+Chr(10))
& Me!Text161

Chr(13) = carriage return and Chr(10) = line feed - doubling it up will give the effect of a new paragraph rather than just a new line.

I tried it with just the Chr(13) in a query (not tested on the code) and I couldn't get it to work but the query worked when I added the line feed.

HTH, Andrew. :)
 
Upvote 0

Forum statistics

Threads
1,221,816
Messages
6,162,149
Members
451,746
Latest member
samwalrus

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top