countryfan_nt
Well-known Member
- Joined
- May 19, 2004
- Messages
- 765
Hello friends, Hope you are well! always!
please help me with the below code please.
1. Please help me make the strbody show in the body of the email. new lines taking effect please.
2. I need the following line to be in both BLUE & ITALICS:
"Should you have any questions, please do not hesitate to ask."
Thank you so much in advance!
please help me with the below code please.
1. Please help me make the strbody show in the body of the email. new lines taking effect please.
2. I need the following line to be in both BLUE & ITALICS:
"Should you have any questions, please do not hesitate to ask."
Thank you so much in advance!
Code:
Sub EmailPDF()
fdir = "c:\temp\"
fname = Sheets("Sheet1").Range("bb7").Value
fpath = fdir & fname & ".pdf"
With Application
.EnableEvents = True
.ScreenUpdating = False
End With
ToAddress = Sheets("Sheet1").Range("bh4").Value
CCAddress = Sheets("Sheet1").Range("bh5").Value
MailSub = fname
'Generate PDF document to c:. Substitute ActiveSheet for ActiveWorkbook to PDF the entire document
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:= _
fpath, Quality:=xlQualityStandard, _
IncludeDocProperties:=False, IgnorePrintAreas:=False, OpenAfterPublish:=False
Dim strbody As String
Dim OutApp As Object
Dim OutMail As Object
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)
'Create Mail & attach PDF
Set oOutlookApp = CreateObject("Outlook.Application")
'Create a new message
Set oItem = oOutlookApp.CreateItem(olMailItem)
With oItem
.To = ToAddress
.CC = CCAddress
.Subject = MailSub
.HTMLBody = strbody
strbody = "Hi there" & vbNewLine & vbNewLine & _
"This is line 1" & vbNewLine & _
"This is line 2" & vbNewLine & _
"This is line 3" & vbNewLine & _
"Should you have any questions, please do not hesitate to ask." & vbNewLine & _
"This is line 5"
'Bring up new mail window
oItem.Display
'Add Attachment
oItem.Attachments.Add fpath
'Cleanup , baby
Set OutMail = Nothing
Set OutApp = Nothing
Set fs = CreateObject("Scripting.FileSystemObject")
fs.deletefile fpath
End With
End Sub