Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

VB6 to Outlook2000: Retrieving sender's email address

Posted on 2001-06-04
10
Medium Priority
?
375 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 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
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!

 
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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
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 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…
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…
Suggested Courses

824 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