Solved

VB6 to Outlook2000: Retrieving sender's email address

Posted on 2001-06-04
10
344 Views
Last Modified: 2010-05-02
I would like tested code in VB6 to obtain the email address of the senders of emails I read using the Outlook Object Model only. The code must exclude use of CDO Object ( which does it but is very clumsy, not everyone has CDO, and CDO is currently crashing my application).
0
Comment
Question by:ozphil
  • 4
  • 3
  • 3
10 Comments
 
LVL 4

Accepted Solution

by:
vindevogel earned 150 total points
ID: 6155935
Using the Microsoft Outlook 9 Reference .....


    Dim vOutlook As Outlook.Application
    Dim vOutlookSpace As Outlook.NameSpace
    Dim vMailFolder As Outlook.MAPIFolder
    Dim vMail As Outlook.MailItem
   
    Set vOutlook = New Outlook.Application
        Set vOutlookSpace = vOutlook.GetNamespace("MAPI")
            Set vMailFolder = vOutlookSpace.Folders.Item("Mailbox - Vindevogel Yves").Folders.Item("Inbox")
           
            For Each vMail In vMailFolder.Items
                vMail.Reply
                MsgBox vMail.To
            Next
           
            Set vMailFolder = Nothing
        Set vOutlookSpace = Nothing
    Set vOutlook = Nothing
0
 
LVL 4

Expert Comment

by:vindevogel
ID: 6155940
change "Mailbox - Vindevogel Yves" into the name in your Outlook (public folder or private folder)
0
 
LVL 4

Author Comment

by:ozphil
ID: 6158415
Thanks I'll try it out.
0
Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

 
LVL 4

Author Comment

by:ozphil
ID: 6158453
vindevogel

I've tried the code, but vMail.to gives me the alias name (eg fredsmith) not fredsmith's email address (xxx@yyy.zzz).

Can you  make you Outlook yield the senders full email adress?
0
 
LVL 4

Author Comment

by:ozphil
ID: 6158466
I think I've stumbled onto the solution:

Dim oReplymail as mailitem
set oReplymail = vMail.Reply
MsgBox oReplymail.recipients(1).address

This ain't documented anywhere.


           

0
 
LVL 4

Author Comment

by:ozphil
ID: 6158976
Well the .Reply was the trigger to the eventual solution. I hadnt thought of doing that. Thanks.
0
 
LVL 4

Expert Comment

by:vindevogel
ID: 6159073
You're welcome ...

I was out of the office when you posted the replies (I'm European), but glad you found the solution yourself.
0
 

Expert Comment

by:iansr
ID: 8371299
Hi everyone,

  I would like to thank you for this post which invariably spared me from missing my deadline. I didn't test out this area (getting the sender's data) since i thought it would be one of the simplest to do. You could just imagine my feeling when I couldn't get the sender's Email (i.e. NO "ObjMail.From" ). Anyway, i am so relieved now, and i owe it to you. So many thanks again and good luck to your projects!

Ian
0
 

Expert Comment

by:iansr
ID: 8371552
Hi everyone,

  I would like to thank you for this post which invariably spared me from missing my deadline. I didn't test out this area (getting the sender's data) since i thought it would be one of the simplest to do. You could just imagine my feeling when I couldn't get the sender's Email (i.e. NO "ObjMail.From" ). Anyway, i am so relieved now, and i owe it to you. So many thanks again and good luck to your projects!

Ian
0
 

Expert Comment

by:iansr
ID: 8371553
Hi everyone,

  I would like to thank you for this post which invariably spared me from missing my deadline. I didn't test out this area (getting the sender's data) since i thought it would be one of the simplest to do. You could just imagine my feeling when I couldn't get the sender's Email (i.e. NO "ObjMail.From" ). Anyway, i am so relieved now, and i owe it to you. So many thanks again and good luck to your projects!

Ian
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

816 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now