Results 1 to 5 of 5

Thread: Extracting an SMTP address!

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Feb 2002
    Posts
    79

    Extracting an SMTP address!

    Hi fellas.

    Not sure if this should be in the VB Script area or not..

    Basically. Want to look in the inbox of Outlook 2000. Find any emails that have been sent from [email protected]. Then grab the smtp email address of the To field and then stuff it into a distribution list call tiddlytesters.

    Not done this at all before...any pointers please??

    Thanks

    B

  2. #2

    Thread Starter
    Lively Member
    Join Date
    Feb 2002
    Posts
    79
    Pretty please any ideas?

    B

  3. #3
    Frenzied Member
    Join Date
    Jan 2001
    Location
    Newbury, UK
    Posts
    1,878
    Which bit do you need help with???

    Running a macro in Outlook?
    Linking from a VB program to Outlook?
    Looking through the Inbox of Outlook?
    Finding the messages you want?
    Getting the TO field?
    Getting the SMTP address from the TO field?

    VB Code:
    1. set OL = GetObject(,"OUTLOOK.APPLICATION")
    2. set MAPI = OL.GetNamespace("MAPI")
    3. Set myItems = MAPI.GetDefaultFolder(6).Items
    4. For each ThisItem in MyItems
    5.     ThisItem.Display
    6. Next
    7. Set myItems = Nothing
    8. Set MAPI = Nothing
    9. Set OL = Nothing

  4. #4

    Thread Starter
    Lively Member
    Join Date
    Feb 2002
    Posts
    79
    Hi chris.

    Looking to get the SMTP address out of the To field in Outlook...then stuffing it into an outlook/exchange disti list.

    Thanks

    B

  5. #5
    Frenzied Member
    Join Date
    Jan 2001
    Location
    Newbury, UK
    Posts
    1,878
    >>Looking to get the SMTP address out of the To field in Outlook...then stuffing it into an outlook/exchange disti list.


    So we can assume that you have the code that steps through all the messages you want....

    You now have a message, and you want to get the TO field from it.

    Have you looked at the MyItem.TO property? BUT the TO property may well show the display name, rather than the SMTP address.
    You might find that you need to look through the Recipients collection within the message item, rather than look at the TO property.


    Adding it into a Distribution List:
    The HELP in Outlook says:
    This Microsoft Visual Basic/Visual Basic for Applications example creates a new distribution list and adds the current user to the list.
    VB Code:
    1. Dim myOlApp As New Outlook.Application
    2. Dim myNameSpace As Outlook.NameSpace
    3. Dim myDistList As Outlook.DistListItem
    4. Dim myTempItem As Outlook.MailItem
    5. Dim myRecipients As Outlook.Recipients
    6. Set myNameSpace = myOlApp.GetNamespace("MAPI")
    7. Set myDistList = myOlApp.CreateItem(olDistributionListItem)
    8. Set myTempItem = myOlApp.CreateItem(olMailItem)
    9. Set myRecipients = myTempItem.Recipients
    10. myDistList.DLName = _
    11.     InputBox("Enter the name of the new distribution list")
    12. myRecipients.Add myNameSpace.CurrentUser.Name
    13. myDistList.AddMembers myRecipients
    14. myDistList.Display

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