Solved

VB6 to Outlook2000: Retrieving sender's email address

Posted on 2001-06-04
10
336 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
 
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
Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

 
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

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
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…
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…

757 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

19 Experts available now in Live!

Get 1:1 Help Now