Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

VB6 to Outlook2000: Retrieving sender's email address

Posted on 2001-06-04
10
Medium Priority
?
370 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
  • 3
10 Comments
 
LVL 4

Accepted Solution

by:
vindevogel earned 600 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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
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 process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses

661 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