VBA to copy email body to worksheet

Cowboyx

New Member
Joined
Jun 28, 2018
Messages
5
Hello everyone,

I am trying to write a code in excel that will copy the selected email body and paste it to the excel sheet. I have merged all the cells required to fit the email and created a button for the user to click and the data to be copied over. Can anyone please help.
 

Excel Facts

Copy PDF to Excel
Select data in PDF. Paste to Microsoft Word. Copy from Word and paste to Excel.
Re: New to VBA Need Help

Here is my code so far: Only problem now is getting he spaces out of the email or reduce them so they fit better. Any suggestions



Private Sub CommandButton1_Click()
Dim olMailItem As Outlook.MailItem
'
' Get the Selected Mail Item and Put the Body in Cell A1
'
Set olMailItem = ActiveExplorer.Selection.Item(1)
Worksheets("SOT Data").Range("A1").Value2 = olMailItem.Body




End Sub
 
Upvote 0

Forum statistics

Threads
1,223,900
Messages
6,175,276
Members
452,629
Latest member
SahilPolekar

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