VBA Email Subject Odd Characters

DrH100

Board Regular
Joined
Dec 30, 2011
Messages
78
Morning all

I'm trying to make my workbook send to an email address listed in the worksheet with a subject title based on one of the cells.

I thought this was working until I noticed the subject line in the email was full of apparently random characters.

Any idea what I can change to put the text from cell b1 in my email subject line? I will admit to stealing the code so if there is something better please let me know.

I am using Excel and Outlook 2016 but would like it to work in 2010 too as we have mixed version atm

The code I am using is

HTML:
Sub Send1Sheet_ActiveWorkbook()
     
    Dim strSubject As String
    Dim strRecip As String
    
    strSubject = Worksheets("mysheet").Range("b1") 
    strRecip = [a1].Value 
    
    
    With ActiveWorkbook
        .SendMail Recipients:=strRecip, Subject:=strSubject
        
    End With
     
End Sub

Many thanks as always
 

Excel Facts

How to create a cell-sized chart?
Tiny charts, called Sparklines, were added to Excel 2010. Look for Sparklines on the Insert tab.
Try this

Code:
Sub Send1Sheet_ActiveWorkbook()     
    Dim strSubject As String
    Dim strRecip As String
    strSubject = Worksheets("mysheet").Range("b1") 
    [COLOR=#0000ff]if strSubject = "" then strSubject  = "No Subject"[/COLOR]
    strRecip = [a1].Value 
    ActiveWorkbook.SendMail Recipients:=strRecip, Subject:=strSubject
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,391
Messages
6,119,247
Members
448,879
Latest member
oksanana

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