Kelly Sprayberry
Member
- Outlook version
- Email Account
- Exchange Server
I need a little help on a macro that will help simplify copying and pasting from a Console terminal window into an email and be able to keep the formatting, yet change the font. What I need to do to make it look right is paste it into the email and then change all the text to "Courier New" from "Calibri" and the spacing and everything looks very close to what is in the terminal window. I can do everything I need to do, but when I change the text using the HTMLBody and font tags, I loose all the spacing and formating of my text string. I guess it's easy enough to just paste the stuff into the email and then highlight it and change the font, but I'd really just like to do it in VBA just because it is stumping me.
Sub sendmyemail()
Dim OutMail As Object
Dim strbody As String
Dim DataObj As MSForms.DataObject
Set DataObj = New MSForms.DataObject
DataObj.GetFromClipboard
strpaste = DataObj.GetText(1)
Set OutMail = Outlook.CreateItem(olMailItem)
With OutMail
.Display
.To = "FOChangelist"
.Subject = "FO Change"
.Body = strpaste
'The above works and I don't lose my spacing and line format, but it is a little jumbled. I paste it and change 'the font and the "jumbledness" goes away and the spacing looks very close to what I need.
'or use the :
.HTMLBody = "<font face=Courier New>" & strpaste & "</font>"
'The above loses all the space and line formatting.
'Example of comments to paste into the body of the email. or something very close
'or use the HTML Body
'1. 01/31/17 01 SERVICE: CONSULT WITH ENGINEERING ON THE BLOWER SPRINGS FOR
' GWM AC-4. THE SPRINGS WERE CHANGED LAST MINUTE AND APPROVED BY
' ENGINEERING.
'2. 01/26/17 01 Per customer AC-6 will ship on 03/15 and be onsite 03/23. Th
' S S e ship/onsite schedule for remaining units stay the same as
' below.
'3. 01/13/17 01 Provide one "empty conduit from control panel to the supply
' NSZ , return duct sections and to NEMA boxes, on units that
' require a NEMA box, for field installation & wiring of
' smoke detectors.
.Display
End With
Set OutMail = Nothing
Set DataObj = Nothing
End Sub
Sub sendmyemail()
Dim OutMail As Object
Dim strbody As String
Dim DataObj As MSForms.DataObject
Set DataObj = New MSForms.DataObject
DataObj.GetFromClipboard
strpaste = DataObj.GetText(1)
Set OutMail = Outlook.CreateItem(olMailItem)
With OutMail
.Display
.To = "FOChangelist"
.Subject = "FO Change"
.Body = strpaste
'The above works and I don't lose my spacing and line format, but it is a little jumbled. I paste it and change 'the font and the "jumbledness" goes away and the spacing looks very close to what I need.
'or use the :
.HTMLBody = "<font face=Courier New>" & strpaste & "</font>"
'The above loses all the space and line formatting.
'Example of comments to paste into the body of the email. or something very close
'or use the HTML Body
'1. 01/31/17 01 SERVICE: CONSULT WITH ENGINEERING ON THE BLOWER SPRINGS FOR
' GWM AC-4. THE SPRINGS WERE CHANGED LAST MINUTE AND APPROVED BY
' ENGINEERING.
'2. 01/26/17 01 Per customer AC-6 will ship on 03/15 and be onsite 03/23. Th
' S S e ship/onsite schedule for remaining units stay the same as
' below.
'3. 01/13/17 01 Provide one "empty conduit from control panel to the supply
' NSZ , return duct sections and to NEMA boxes, on units that
' require a NEMA box, for field installation & wiring of
' smoke detectors.
.Display
End With
Set OutMail = Nothing
Set DataObj = Nothing
End Sub