How to edit this email from Excel VBA code to put body text after pasted info with signature?

Indominus

Board Regular
Joined
Jul 11, 2020
Messages
160
Office Version
  1. 2016
Platform
  1. Windows
Hi. I have this VBA code that copies the current range starting from A1 and emails it out. It works however, the body text gets put below the pasted info and there is no signature. If I remove the body text the signature is there. How can I edit this to put the body text on the top and still include the signature. My signature also includes a picture if that matters. Here is the code. Thank you in advance!

VBA Code:
Sub Email()

Dim xAddress As String
Dim xEmailBody As String
Dim xMailOut As Outlook.MailItem
Dim xOutApp As Outlook.Application



xAddress = ActiveWindow.RangeSelection.Address


Application.ScreenUpdating = False
Set xOutApp = CreateObject("Outlook.Application")
Set xMailOut = xOutApp.CreateItem(olMailItem)


Range("A1").CurrentRegion.Copy


xMailOut.To = Worksheets("Setup").Range("V2").Value
xMailOut.CC = Worksheets("Setup").Range("V3").Value
xMailOut.Subject = Worksheets("Setup").Range("V4").Value
xMailOut.body = Worksheets("Setup").Range("V5").Value


xMailOut.display
SendKeys "^{v}", True



Set xMailOut = Nothing
Set xOutApp = Nothing
Application.ScreenUpdating = True



'Application.CutCopyMode = False
End Sub
 

Excel Facts

Did you know Excel offers Filter by Selection?
Add the AutoFilter icon to the Quick Access Toolbar. Select a cell containing Apple, click AutoFilter, and you will get all rows with Apple
To solve your first issue about adding in the signature, you need to .Display before you set any other of the email parameters, as in this example. I don't know exactly how MailItem handles setting the properties and how it relates to the clipboard programmatically, but maybe try appending your clipboard to "Worksheets("Setup").Range("V5").Value" and setting that combined value to .Body.
 
Upvote 0

Forum statistics

Threads
1,224,818
Messages
6,181,151
Members
453,021
Latest member
Justyna P

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