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

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
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,224,823
Messages
6,181,177
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