Solved

VB6 to Outlook2000: Retrieving sender's email address

Posted on 2001-06-04
10
339 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
DO Loop not working 4 72
VB6 - Compare and highlight cell not the same 3 44
Add a task in Outlook from access 11 35
Recommendation vb6 to vb.net or others 14 114
When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…

863 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

27 Experts available now in Live!

Get 1:1 Help Now