A Microsoft Outlook email forum. Outlook Banter

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » Outlook Banter forum » Microsoft Outlook Email Newsgroups » Outlook and VBA
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

Forward Email and Insert Sender's Email address in body



 
 
Thread Tools Search this Thread Display Modes
  #1  
Old May 20th 10, 03:47 PM posted to microsoft.public.outlook.program_vba
LDMueller
external usenet poster
 
Posts: 53
Default Forward Email and Insert Sender's Email address in body

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 = "
fwdItem.subject = "Whitelist"
fwdItem.HTMLBody = "pPlease whitelist the following:/pp/p" &
vbCrLf & _
"Senders Email Address Here" & _
vbCrLf & fwdItem.HTMLBody
fwdItem.Send
End Sub

Can anyone help me?

Thanks so much in advance!

LDMueller
Ads
  #2  
Old May 20th 10, 04:06 PM posted to microsoft.public.outlook.program_vba
Ken Slovak - [MVP - Outlook]
external usenet poster
 
Posts: 5,848
Default Forward Email and Insert Sender's Email address in body

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.

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Professional Programming Outlook 2007.
Reminder Manager, Extended Reminders, Attachment Options.
http://www.slovaktech.com/products.htm


"LDMueller" wrote in message
...
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 = "
fwdItem.subject = "Whitelist"
fwdItem.HTMLBody = "pPlease whitelist the following:/pp/p" &
vbCrLf & _
"Senders Email Address Here" & _
vbCrLf & fwdItem.HTMLBody
fwdItem.Send
End Sub

Can anyone help me?

Thanks so much in advance!

LDMueller


  #3  
Old May 20th 10, 05:04 PM posted to microsoft.public.outlook.program_vba
LDMueller
external usenet poster
 
Posts: 53
Default Forward Email and Insert Sender's Email address in body

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!


"Ken Slovak - [MVP - Outlook]" 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.

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Professional Programming Outlook 2007.
Reminder Manager, Extended Reminders, Attachment Options.
http://www.slovaktech.com/products.htm


"LDMueller" wrote in message
...
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 = "
fwdItem.subject = "Whitelist"
fwdItem.HTMLBody = "pPlease whitelist the following:/pp/p" &
vbCrLf & _
"Senders Email Address Here" & _
vbCrLf & fwdItem.HTMLBody
fwdItem.Send
End Sub

Can anyone help me?

Thanks so much in advance!

LDMueller


.

  #4  
Old May 20th 10, 08:31 PM posted to microsoft.public.outlook.program_vba
Ken Slovak - [MVP - Outlook]
external usenet poster
 
Posts: 5,848
Default Forward Email and Insert Sender's Email address in body

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.

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Professional Programming Outlook 2007.
Reminder Manager, Extended Reminders, Attachment Options.
http://www.slovaktech.com/products.htm


"LDMueller" wrote in message
...
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!


 




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Forward Email to include Senders email address in the body LDMueller Outlook and VBA 0 May 20th 10 02:21 PM
Forward email as insert from button mikey014 Outlook and VBA 1 March 16th 10 03:37 PM
I have to find the sender's email address win Outlook and VBA 1 January 28th 10 04:32 PM
VBA to insert Hyperlink in Email Body K[_3_] Outlook and VBA 0 April 23rd 09 04:55 PM
insert as text (to insert html into email body) Iona Outlook - General Queries 1 July 13th 06 01:10 PM


All times are GMT +1. The time now is 08:08 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.Search Engine Friendly URLs by vBSEO 2.4.0
Copyright ©2004-2025 Outlook Banter.
The comments are property of their posters.