New Message From Sender

Last reviewed on July 2, 2012

This macro demonstrates how to pick up the sender's address and use it for a new message. This was originally put together for a user who wanted to send email using the address of one of several shared mailbox automatically. Beyond using it for redirecting mail, it's more of a concept macro, showing how to grab the sender's address from an email email. Otherwise, it's probably not very useful to most people.

Public Sub SendFromAddressOfCurrentEmail()
    Dim Session As Outlook.NameSpace
    Dim currentExplorer As Explorer
    Dim Selection As Selection
    Dim currentItem As Object
    Dim currentMail As MailItem
    Dim smtpAddress As String

    Set currentExplorer = Application.ActiveExplorer
    
    Set Selection = currentExplorer.Selection
     For Each currentItem In Selection
        If currentItem.Class = olMail Then
            Set currentMail = currentItem
            smtpAddress = currentMail.SenderEmailAddress
        End If
    Next
   
Dim oMail As Outlook.MailItem
 
' Send new message 
' Set oMail = Application.CreateItem(olMailItem)

'Send reply 
Set oMail = Application.ActiveExplorer.Selection(1).Reply

oMail.SentOnBehalfOfName = smtpAddress
      oMail.Display
    
End Sub

To send a message using the To address, change smtpAddress = currentMail.SenderEmailAddress to smtpAddress = currentMail.To

        If currentItem.Class = olMail Then
            Set currentMail = currentItem
            smtpAddress = currentMail.To
        End If

Written by

Diane Poremsky
A Microsoft Outlook Most Valuable Professional (MVP) since 1999, Diane is the author of several books, including Outlook 2013 Absolute Beginners Book. She also created video training CDs and online training classes for Microsoft Outlook. You can find her helping people online in Outlook Forums as well as in the Microsoft Answers and TechNet forums.

If the Post Coment button disappears, press your Tab key.