VBA to send email with specific subject

pete4monc

Board Regular
Joined
Jan 12, 2014
Messages
85
Office Version
  1. 365
Platform
  1. Windows
Hi guys

I have compiled a vba to send emails through a web client using CDO, which works perfectly well. Which I can share if anyone needs it?
BUT I am struggling with one bit.
The code is quite large as it does a number of actions so I have cut all the other bits out and just included the section I am struggling with. I would like to send the order number which is in column B of the active sheet and row in the subject header of the email? It sends the email with the body text correct but the header comes out with "Review OrderTrue" without the text in cell B??
Please could some one point me in the right direction? Thanks.

VBA Code:
Dim var As Variant: var = Range("B" & (ActiveCell.Row)).Select
   
    strbody = "Hi" & vbNewLine & vbNewLine & _
        "Please review the above order and forward to next department" & vbNewLine & _
        "Thank you"
       
   
    With iMsg
        Set .Configuration = iConf
        .To = "p******************.com"
        .CC = ""
        .BCC = ""
        .From = """Pete"" <p****************.com>"
        .Subject = "Review Order" & var
        .TextBody = strbody
        .Send
    End With

    Set iMsg = Nothing
    Set iConf = Nothing
    Set Flds = Nothing
End Sub

Thanks
Pete
 

Excel Facts

Convert text numbers to real numbers
Select a column containing text numbers. Press Alt+D E F to quickly convert text to numbers. Faster than "Convert to Number"
Hello,

think it might be first line

VBA Code:
Dim var As Variant: var = Range("B" & (ActiveCell.Row)).Value
 
Upvote 0
Hello,

think it might be first line

VBA Code:
Dim var As Variant: var = Range("B" & (ActiveCell.Row)).Value

Hi, thanks for your input.
I figured it is in that bit of vba, but I have tried other variants but don't know why that is not working. Any ideas?
 
Upvote 0

Forum statistics

Threads
1,214,646
Messages
6,120,718
Members
448,986
Latest member
andreguerra

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