Paste into body of email Vba

zone709

Well-known Member
Joined
Mar 1, 2016
Messages
2,079
Office Version
  1. 365
Platform
  1. Windows
HI,

Working on a macro and need help. Just trying to paste this range below into the body of an email in outlook.

I already copied range opened email with vba. I just don't know how to paste this below into body of email. As I can not record it see the outcome.


Code:
Range("B4:H11").Copy

Thanks
 

Excel Facts

Control Word Wrap
Press Alt+Enter to move to a new row in a cell. Lets you control where the words wrap.
do i need to put in here what i did so far?
 
Upvote 0
Don't know about pasting into the body of an email but if you look here you'll find code to add a range, as HTML, to the body of an email.
 
Upvote 0
Hi thanks for the reply. I am working on something that opens my sheet then opens outlook. Which i did already. I just need to take this below from the activesheet all the time and put it into the body of email. I don't think it needs to paste maybe a different way?

Excel 2010 32 bit
B
C
D
2
Cost​
Cost to Date​
3
$ 50.00​
$ 50.00​
4
$ 100.00​
$ 100.00​
Sheet: Sheet1



i am using B2 range to D4 better example
 
Last edited:
Upvote 0
Hi thanks for the reply. I am working on something that opens my sheet then opens outlook. Which i did already. I just need to take this below from the activesheet all the time and put it into the body of email. I don't think it needs to paste maybe a different way?

Excel 2010 32 bit
B
C
D
2
Cost​
Cost to Date​
3
$ 50.00​
$ 50.00​
4
$ 100.00​
$ 100.00​
Sheet: Sheet1



i am using B2 range to D4 better example

Wait could i just add into my code below
objMail
.HTLMBody = fncRangeToHtml("Sheet1", "B2:D4") ?
 
Upvote 0
Can't really tell without seeing your current code.:)
 
Upvote 0
So this is what I have already. For some reason I cant run it now to test it. It says "Compile Errror Expected Function or Variable" every time I run it. So I couldn't test this either -->
Code:
[LEFT][COLOR=#222222][FONT=Verdana] .HTLMBody = fncRangeToHtml("Sheet1", "B2:D4") 
[/FONT][/COLOR][/LEFT]

So below is mostly what I need it to do plus copy that range and put into body. The excel file will always be open and the tab name is Sheet1.


Code:
Sub Run780()
    With Application
        .DisplayAlerts = False
        .ScreenUpdating = False
        .EnableEvents = False
    End With
    
    Emails = "frank.com;"
    Set OutApp = CreateObject("Outlook.Application")
    Set OutMail = OutApp.CreateItem(0)
    
    With OutMail
        .Display
    End With
    Signature = OutMail.HTMLBody
    With OutMail
        .To = Emails
        .Cc = "frank.com;"
        .Subject = "Numbers"
        .HTLMBody = fncRangeToHtml("Sheet1", "B2:D4") '-- Didnt test this part yet cause it gives a compile error--'
        .HTMLBody = Signature
    End With
    
    With Application
        .DisplayAlerts = True
        .ScreenUpdating = True
        .EnableEvents = True
    End With
    
    Set OutMail = Nothing
    Set OutApp = Nothing
    
    End Sub
 
Upvote 0
I think I figured out the compile error. I have another sub with the a name in this code. Will fix it tomorrow and test this again. Not sure if that HTLMBody will work well see
 
Upvote 0

Forum statistics

Threads
1,214,596
Messages
6,120,438
Members
448,966
Latest member
DannyC96

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