Results 1 to 3 of 3

Forward Email Based on Selected Object's Subject and/or Sender and Recipient Address

Threaded View

  1. #2
    Forum Contributor
    Join Date
    08-27-2006
    Posts
    136

    Re: Forward Email Based on Selected Object's Subject and/or Sender and Recipient Address

    This demonstrates how you could determine the text associated with the sender and the recipients.

    Option Explicit
    
    Sub CheckRecipients()
    
    Dim currItem As Object
    Dim currMail As MailItem
    Dim recip As recipient
    
    Set currItem = GetCurrentItem
    
    If TypeOf currItem Is MailItem Then
    
        Set currMail = currItem
    
        Debug.Print "Sender            : " & currMail.Sender
        Debug.Print "SenderName        : " & currMail.senderName
        Debug.Print "SenderEmailAddress: " & currMail.SenderEmailAddress
        Debug.Print
        
        For Each recip In currMail.Recipients
    
            If recip.Type = olTo Then
                Debug.Print recip & " is in the To line."
    
                If recip = "the text in the Debug.Print line" then
                    ' code for recipients in the to line
                End if
    
            ElseIf recip.Type = olCC Then
                Debug.Print recip & " is in the cc line."
            Else
                Debug.Print recip & " is in the bcc line." ' Item in sent items folder
            End If
        
        Next recip
    
    End If
    
    Set currItem = Nothing
    Set currMail = Nothing
    
    End Sub
    
    Private Function GetCurrentItem() As Object
    
    Select Case TypeName(Application.ActiveWindow)
        Case "Explorer"
            Set GetCurrentItem = Application.ActiveExplorer.Selection.item(1)
        Case "Inspector"
            Set GetCurrentItem = Application.ActiveInspector.currentItem
    End Select
    
    End Function
    You could try to determine SMTP addresses, those with the @ sign, but that is a bit more complicated.
    Last edited by skatonni; 06-01-2015 at 05:33 PM.
    To mark "Solved" go to Thread Tools.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Getting SMTP Email Address of an Exchange Sender
    By RhettL in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 06-16-2014, 11:12 PM
  2. [SOLVED] Recovering the default sender outlook email address from vba on excel
    By Alain-79 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-08-2013, 03:53 AM
  3. [SOLVED] VBA to open a new email, (outlook) add the recipient, and the subject of 'Issue Found'
    By galvinpaddy in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-09-2012, 03:42 AM
  4. Replies: 1
    Last Post: 03-08-2012, 01:57 PM
  5. Replies: 6
    Last Post: 12-02-2011, 02:14 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1