Forward Email and Insert Sender's Email address in body

Status
Not open for further replies.
L

LDMueller

With the help of this awesome site, I've created the following code. The

only part which I can't figure out is how to insert the email address of the

sender in the

"Senders Email Address Here" area.

Sub Whitelist()

On Error Resume Next

Set ThisItem = Application.ActiveInspector.CurrentItem

Set fwdItem = ThisItem.Forward

fwdItem.To = "lmueller@company.com"

fwdItem.subject = "Whitelist"

fwdItem.HTMLBody = "<p>Please whitelist the following:</p><p></p>" &

vbCrLf & _

"Senders Email Address Here" & _

vbCrLf & fwdItem.HTMLBody

fwdItem.Send

End Sub

Can anyone help me?

Thanks so much in advance!

LDMueller
 
One post would have been enough.

You want the sender's email address from the ThisItem object?

Use ThisItem.SenderEmailAddress for that. Be aware though that if your

sender is an Exchange user in the same domain you are in (if you use

Exchange) that the result will be an Exchange DN and not an SMTP address.

"LDMueller" <LDMueller> wrote in message

news:EA7810DE-262B-44F1-851A-E17CD771CA75@microsoft.com...
> With the help of this awesome site, I've created the following code. The
> only part which I can't figure out is how to insert the email address of
> the
> sender in the
> "Senders Email Address Here" area.

> Sub Whitelist()
> On Error Resume Next
> Set ThisItem = Application.ActiveInspector.CurrentItem
> Set fwdItem = ThisItem.Forward
> fwdItem.To = "lmueller@company.com"
> fwdItem.subject = "Whitelist"
> fwdItem.HTMLBody = "<p>Please whitelist the following:</p><p></p>" &
> vbCrLf & _
> "Senders Email Address Here" & _
> vbCrLf & fwdItem.HTMLBody
> fwdItem.Send
> End Sub

> Can anyone help me?

> Thanks so much in advance!

> LDMueller
 
Sorry about the duplicate post. When I went back to check the status and

didn't see the orginal one, I thought perhaps I didn't post it properly.

I tried your suggestion and it worked except my sender is an Exchange user.

Is there any way around this?

Also, the way I have it written, I have to have the email open for the macro

to work. Is there a way to have it work when the email is currently selected?

Thanks so much for your help. I really appreciate it!
wrote:


> One post would have been enough.

> You want the sender's email address from the ThisItem object?

> Use ThisItem.SenderEmailAddress for that. Be aware though that if your
> sender is an Exchange user in the same domain you are in (if you use
> Exchange) that the result will be an Exchange DN and not an SMTP address.

> >

>

> "LDMueller" <LDMueller> wrote in message
> news:EA7810DE-262B-44F1-851A-E17CD771CA75@microsoft.com...
> > With the help of this awesome site, I've created the following code. The
> > only part which I can't figure out is how to insert the email address of
> > the
> > sender in the
> > "Senders Email Address Here" area.
> > Sub Whitelist()
> > On Error Resume Next
> > Set ThisItem = Application.ActiveInspector.CurrentItem
> > Set fwdItem = ThisItem.Forward
> > fwdItem.To = "lmueller@company.com"
> > fwdItem.subject = "Whitelist"
> > fwdItem.HTMLBody = "<p>Please whitelist the following:</p><p></p>" &
> > vbCrLf & _
> > "Senders Email Address Here" & _
> > vbCrLf & fwdItem.HTMLBody
> > fwdItem.Send
> > End Sub
> > Can anyone help me?
> > Thanks so much in advance!
> > LDMueller


> .
>
 
Assuming only 1 item is selected:

Application.ActiveExplorer.Selection.Item(1) instead of the

Inspector.CurrentItem.

What Outlook version are you using? If you are using Outlook 2007 or later

you can get the SMTP address, if you are using an earlier version of Outlook

you'd need to use a different, lower level API to get that property, which

isn't exposed in Outlook 2003 or earlier.

"LDMueller" <LDMueller> wrote in message

news:94A42E33-AF69-47AC-BC7B-3B9B82ED40F1@microsoft.com...
> Sorry about the duplicate post. When I went back to check the status and
> didn't see the orginal one, I thought perhaps I didn't post it properly.

> I tried your suggestion and it worked except my sender is an Exchange
> user.
> Is there any way around this?

> Also, the way I have it written, I have to have the email open for the
> macro
> to work. Is there a way to have it work when the email is currently
> selected?

> Thanks so much for your help. I really appreciate it!
 
Status
Not open for further replies.
Similar threads
Thread starter Title Forum Replies Date
M Forward email as insert from button Outlook VBA and Custom Forms 1
D Outlook VBA forward the selected email to the original sender’s email ID (including the email used in TO, CC Field) from the email chain Outlook VBA and Custom Forms 2
J Outlook 365 Forward Email Subject to my inbox when new email arrive in shared inbox Using Outlook 0
L Fetch, edit and forward an email with VBA outlook Outlook VBA and Custom Forms 2
richardwing Auto forward email that is moves into a specific outlook folder Outlook VBA and Custom Forms 5
A Outlook 2016 Macro to Reply, ReplyAll, or Forward(but with composing new email) Outlook VBA and Custom Forms 0
F Forward incoming email with 4 embedded images in the body without original sender Outlook VBA and Custom Forms 22
G Forward email body to other mail list directly from Exchange server Exchange Server Administration 1
D auto forward base on email address in body email Outlook VBA and Custom Forms 0
Bering Forward selected email without the original email appended Outlook VBA and Custom Forms 0
J Automatically forward email and apply template Outlook VBA and Custom Forms 0
O Forward a email with modified body Automatically. Outlook VBA and Custom Forms 0
C How to rename subject line and forward the email Outlook VBA and Custom Forms 2
R Error when trying to forward current email item Outlook VBA and Custom Forms 7
B Forward every other email in Outlook 2013 Outlook VBA and Custom Forms 2
D Disable or hide "reply" and "reply to all" and "forward" in email from access vba Outlook VBA and Custom Forms 1
Sabastian Samuel HOW DO I FORWARD AN EMAIL WITH MACRO using an email that in the body of another email Outlook VBA and Custom Forms 3
A Forward Outlook Email by Filtering using Macro Rule Outlook VBA and Custom Forms 44
Brostin Forward a mail to the address listed in the email text Outlook VBA and Custom Forms 1
A Creating an outlook rule to forward an email with a specific message Using Outlook 1
D How to forward each email x minutes after it arrives in inbox and hasn't been moved or deleted? Using Outlook 1
W Macro to forward email Outlook VBA and Custom Forms 2
mikecox Forward email to another address; not with Rules Using Outlook 3
divan Macro to format email in a certain folder then forward to email address Using Outlook 3
D forward email with attachment using .oft Using Outlook 3
R Auto-create receipt from email and forward to payer Using Outlook 3
C Unable to forward email with URL Using Outlook 2
M rule to change subject, pull email addresses from body, and forward with templ Using Outlook 14
S Rule to Auto-forward/re-direct a specific incoming email to a group via BCC? Using Outlook 1
A Outlook 2010 - Want to Have All Email Reply Forward as Rich Test Using Outlook 7
P email arrows - respond and forward Using Outlook 1
J Rule to Forward email but delay delivery 10 minutes Outlook VBA and Custom Forms 2
S forward email Outlook VBA and Custom Forms 1
A Forward mails with "FW:" or "RE:" in title Using Outlook 2
D Outlook 365 Forward Meeting Related Messages to Specific Meeting Organizer Outlook VBA and Custom Forms 0
T Customized form: The Forward option shows write layout Outlook VBA and Custom Forms 0
Z VBA Forward vs manual forward Outlook VBA and Custom Forms 2
David McKay VBA to manually forward using odd options Outlook VBA and Custom Forms 1
S Auto forward for multiple emails Outlook VBA and Custom Forms 0
C UDFs Reply vs Forward Outlook VBA and Custom Forms 3
M In Outlook Calendar remove the buttons: 'Today' and '<' (Back a day) and '>' (Forward a day) that are below the Ribbon and above the calendar display. Using Outlook 0
M Outlook macro to automate search and forward process Outlook VBA and Custom Forms 6
G Missing forward/replied icons Using Outlook 2
M VBA to auto forward message with new subject and body text Outlook VBA and Custom Forms 8
B Automatically Forward Emails and Remove/Replace All or Part of Body Outlook VBA and Custom Forms 8
M Forward Appointment as BCC with VBScript Outlook VBA and Custom Forms 7
C Don't forward duplicate Using Outlook 0
undercover_smother Automatically Forward All Sent Mail and Delete After Send Outlook VBA and Custom Forms 10
I change subject and forward without FW: Outlook VBA and Custom Forms 4
C VBA to Forward e-mails from certain address and between certain times Outlook VBA and Custom Forms 1

Similar threads

Back
Top