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
 
K

Ken Slovak - [MVP - Outlook]

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
 
L

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


> .
>
 
K

Ken Slovak - [MVP - Outlook]

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.
Thread starter Similar threads Forum Replies Date
M Forward email as insert from button Outlook VBA and Custom Forms 1
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
T Using A Rule To Forward An Email Containing Specific Word Using Outlook 5
D I would like to be able to Forward a Template to a specified email address on receiving an email in the Inbox. Using Outlook 1
L Automatically forward ALL outgoing/sent emails to another email adddress (not just for a specific distribution list) Using Outlook 2
T Exchange - forward email when user is not logged on Using Outlook 1
I Outlook 2007 Out of office Forward of email sent to a Distribution List member Using Outlook 1
O Can't send, reply, or forward email. Using Outlook 2
A Forward an entire email folder including the folder structure Using Outlook 2
P no text in forward email Using Outlook 2
A Outlook crashes and restart when I send, reply or forward an email Using Outlook 1
J Can not reply to or forward email from outlook but can send email started from new Using Outlook 1
O Email tool bar greyed out. Can't send or forward email. Using Outlook 1
R Exchange Powershell getting the forward email address for mailboxes Exchange Server Administration 2
A forward all email to another smtp server? Exchange Server Administration 5
B Outlook 2010 auto-forward deletes message text from forwarded email Using Outlook 7
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
C UDFs Reply vs Forward Outlook VBA and Custom Forms 2
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
J Forward Action in Form Outlook VBA and Custom Forms 1
Similar threads


















































Top