Results 1 to 13 of 13

Thread: How do you retrieve an Email Address

  1. #1

    Thread Starter
    Big D Danial's Avatar
    Join Date
    Jul 2000
    Location
    ASP.Net Forum
    Posts
    2,877
    Depends, if your users are using MS Outlook then it would be pretty simple, just add an reference to the MS Outlook object.
    [VBF RSS Feed]

    There is a great war coming. Are you sure you are on the right side? Atleast I have chosen a side.

    If I have been helpful, Please Rate my Post. Thanks.

    This post was powered by :

  2. #2
    Hyperactive Member MarkusJ_NZ's Avatar
    Join Date
    Jun 2001
    Posts
    375
    Hi, believe it or not there is no actual email address which you can reference from the incoming email via Outlook Objects.

    I tried for ages to work this out and finally I figured that you have to create a copy of the incoming mail object, reply to it and from there you can get the email to respond to;

    Code:
    'oMail is the current mail object (Incoming mail object)
    
    Dim objMessage As Outlook.MailItem
    Dim objMessageCopy As Outlook.MailItem
    
    Dim sEmail As String
    
    Set objMessage = oMail
    Set objMessageCopy = objMessage.Reply
            
    sEmail = objMessageCopy.Recipients(1).AddressEntry.Address
    
    ' sEmail now holds the reply to email address
    If anyone has an easier way to get this information, I'm all ears!!!!

    Cheers
    MarkusJ

  3. #3
    Fanatic Member
    Join Date
    Mar 2001
    Location
    Southern California
    Posts
    733
    Markus,

    Of the following 3 statements, which one would be considered the "oMail" object?

    Set colApp = CreateObject("Outlook.Application")
    Set colNameSpace = colApp.GetNamespace("MAPI")
    Set colFolders = colNameSpace.GetDefaultFolder(olFolderInbox)

    Thanks,
    Jeff

  4. #4
    Fanatic Member
    Join Date
    Mar 2001
    Location
    Southern California
    Posts
    733
    Markus,

    I tried your code and I'm not sure if I got it right. Look at my previous message post. I have also attached a screen print of the program. What is supposed to show up in the "E-mail Messages" window are Recipient Email Addresses. Only 1 shows up the way I want it to.

    Any ideas?

    Thanks,
    Jeff

  5. #5
    Fanatic Member
    Join Date
    Mar 2001
    Location
    Southern California
    Posts
    733
    Yo Markus....any ideas?

  6. #6
    Fanatic Member
    Join Date
    Mar 2001
    Location
    Southern California
    Posts
    733
    Does anybody have any idea???

  7. #7
    Hyperactive Member MarkusJ_NZ's Avatar
    Join Date
    Jun 2001
    Posts
    375
    Hi Jeffo..

    The following is a piece of code which goes through all the messages in your inbox, looks for a specific subject and then raises an event and passes the current mailobject to a routine.

    If you use this inconjunction with the code I posted earlier you should be ok

    Code:
    ' Variables used to create the outlook object
    Private myOLApp As New Outlook.Application
    Private olNameSpace As Outlook.NameSpace
    Private myFolder As Outlook.MAPIFolder
    Private olMapi As Object
    
    ' Subroutine which is used to go through all the emails in the inbox
    Public Sub traverse()
    
    Dim i As Integer
    Dim strSubject As String
    Dim strSender As String
    Dim strBody As String
    Dim strOwnerBox As String
    
        ' For each email in the inbox
        For i = 1 To myFolder.Items.Count
            ' get the subject
            strSubject = myFolder.Items(i).Subject
        
            ' If the subject is a reponse from the internet site then
            If Trim(strSubject) = "|product-purchase|" Then
                ' Raise the ResponseMail event which will extract all information from the email
                ' and store the information into the database
                RaiseEvent ResponseMail(myFolder.Items(i).SenderName, myFolder.Items(i).Body, myFolder.Items(i).ReplyRecipientNames)
    
     '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
    ' This is the oMail object here
    
                RaiseEvent LogResponse(myFolder.Items(i))
     '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
                 End If
           
        Next
    
    End Sub
    HTH
    Regards
    Mark

  8. #8
    Fanatic Member
    Join Date
    Mar 2001
    Location
    Southern California
    Posts
    733
    Mark,

    I believe your code will work, but I'm not real sure how to integrate it with the code you gave me before.

    JO

  9. #9
    Hyperactive Member MarkusJ_NZ's Avatar
    Join Date
    Jun 2001
    Posts
    375
    Hi Jeffo, attached is a form which allows a user to click on a button. All the emails in the Inbox of outlook are then added to a listbox for you to view. To use it create a new project and add the form in, run the form click on the button and all the emails that are in your Inbox should appear in the listbox.

    I just wrote this real quick but it should be enough to get you going

    Don't forget to add a reference to the Microsoft Outlook object library (Im using Microsoft Outlook 9.0 object library)

    Cheers
    Mark

  10. #10
    Fanatic Member
    Join Date
    Mar 2001
    Location
    Southern California
    Posts
    733
    Markus,

    I really appreciate your help in this matter. I did what you said
    and unfortunately, it didn't display the email addresses. I've attached a print screen of what the results are. Maybe there are some settings that need to be changed on my computer or something.

    Thanks again!
    Jeff

  11. #11
    Hyperactive Member MarkusJ_NZ's Avatar
    Join Date
    Jun 2001
    Posts
    375
    Hi Jeffo, Damn thats weird!!

    The code that I wrote works ok under Windows 2000 along-side Microsoft Outlook 2000. Unfortunately thats all I have access to...

    Whats specs are you using???
    Cheers
    Mark

  12. #12
    Fanatic Member
    Join Date
    Mar 2001
    Location
    Southern California
    Posts
    733
    Markus,

    I'm developing the specs myself. I am running Windows NT and using MS Outlook 97. That output is really strange. I don't know what else to do. How bout you?

    Jeff

  13. #13
    Hyperactive Member MarkusJ_NZ's Avatar
    Join Date
    Jun 2001
    Posts
    375
    Hi Jeff, Sorry mate, that really has me baffled

    I only have access to outlook 2000 under windows 2000 proferssional...

    I really am out of ideas now

    Hope you get it going somehow
    Cheers
    Markus

Posting Permissions

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



Click Here to Expand Forum to Full Width