outlook-Automatically Insert Recipient Name from To Field

Trevor3007

Well-known Member
Joined
Jan 26, 2017
Messages
667
Office Version
  1. 365
Platform
  1. Windows
hi,

i know this is possible as i have seen it, but I cannot now find it on the web ( some very near to, but not actual)

From the To: field bill.james@riddle.com

and in the body of message

the VB will automatically put in

Hello bill, (including "," )

This would be ran from a macro, can someone much much cleaver than I, send me the applicable VB code please
 

Excel Facts

Highlight Duplicates
Home, Conditional Formatting, Highlight Cells, Duplicate records, OK to add pink formatting to any duplicates in selected range.
Have you considered creating a template email for this recipient?
 
Upvote 0
Have you considered creating a template email for this recipient?
hi Domenic,
yes I have, but I have over 1500 to do and cannot multi send or bcc. each have to have a 'individual' email sent to them with in the body of the message

hi 'name'

thanks anyhoo
 
Upvote 0
In that case, you'll need to provide additional information, explaining exactly how you want the process to unfold, and then someone will likely be able to help.

Cheers!
 
Upvote 0
ok thank you.
1622623430922.png

from the the example above, copy jonathan

into the body of the message and after

Hi ,

so it will look like

Hi jonathan ,

hoping this helps & thanks again.
 
Upvote 0
Unfortunately, you haven't added any new information, so it's unclear as to how you want the process to unfold. Are you running the macro from Excel or Outlook? Are you creating a new email or do you want that information copied to an existing and active email?

Here's a macro that you can run from Excel. It simply creates a new email, fills in the relevant fields, and displays the email...

VBA Code:
Sub Insert_Recipient()

    Dim outlookApp As Object
    Set outlookApp = CreateObject("Outlook.Application")
    
    Dim outlookMailItem As Object
    Set outlookMailItem = outlookApp.CreateItem(0)
    
    With outlookMailItem
        .to = "bill.james@riddle.com"
        .body = "Hi Bill," & vbCrLf & vbCrLf
        .display
        '.send
    End With
    
    Set outlookMailItem = Nothing
    Set outlookApp = Nothing
 
Upvote 0
thanks.. sorry for not .

(may bad) I should of also stated that the VB has to run from outlook as the excel spreadsheet I am using is on a shared platform & using VB on it causes issues. ?
 
Upvote 0
In that case, you can change it to the following...

VBA Code:
Sub Insert_Recipient()

    Dim theMailItem As MailItem
    Set theMailItem = Application.CreateItem(olMailItem)
    
    With theMailItem
        .To = "bill.james@riddle.com"
        .Body = "Hi Bill," & vbCrLf & vbCrLf
        .Display
        '.send
    End With
    
    Set theMailItem = Nothing
    
End Sub
 
Upvote 0
Many I will give it test Thursday and advise u soon as .
 
Upvote 0
hi,
I could not wait until Thursday to test.

Ran the VB , but it changes the the recipient name & changes it to whats in the VB (bill.james@riddle.com)


and in the body of the message

inserts "Hi Bill,"
 
Upvote 0

Forum statistics

Threads
1,215,054
Messages
6,122,901
Members
449,097
Latest member
dbomb1414

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