Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Visual Basic > VB 2005 > Pro Visual Basic 2005
Pro Visual Basic 2005 For advanced Visual Basic coders working in version 2005. Beginning-level questions will be redirected to other forums, including Beginning VB 2005.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Pro Visual Basic 2005 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old November 1st, 2007, 05:49 AM
Registered User
Join Date: Nov 2007
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default CDO - MAPI - Email - AddressBook Access Question


As some of you may know when using MAPI or Outlook to send emails. When you try to extract the email address out of the email it either shows you the name of the person or the exchange server name & name & id and random stuff see below.

Name = Iles, Kevin
Email = EX:/o=CorpLAN/ou=First Administrative Group/cn=Recipients/cn=IlesK

I am using MAPI to send emails and using the 'name' to send emails is fine as the name can be resolved by the address book. Which is good.

And some of you may also know you cannot send HTML Emails using Simple MAPI, so what i am doing instead is using SMTP to send out HTML Emails.

One problem, if im reading emails from MAPI and sending with SMTP, the only names i can get are the ones listed above. Inside the profile is a POP3 address that emails can be sent to (for use by external people) so what i need is to get the POP3 Email. After allot of searching i have finally found some code that does this

This is a console application.

## With reference to
Microsoft CDO 1.21 Library

Imports Microsoft.Office.Interop

Module Module1


    Sub main()

        Dim objSession As MAPI.Session
        Dim objMessage As MAPI.Message
        Dim objRecip As MAPI.Recipient
        Dim objField As MAPI.Field
        Dim v

        objSession = CreateObject("MAPI.Session")

        objMessage = objSession.Outbox.Messages.Add
        objMessage.Recipients = objSession.AddressBook(OneAddress:=True)

        objRecip = objMessage.Recipients(1)

        MsgBox("Display Name: " & objRecip.Name)
        MsgBox("Default Address: " & objRecip.Address)

        objField = _

        For Each v In objField.Value
            MsgBox("Foreign System Address: " & v)


    End Sub

End Module
this does exactly what i want. it pops up and allows you to select a user/profile to load, then it will tell you the

Exchange Email
All POP3 Email accounts.

Which is excellent. but the problem is the 'Popup' where it allows you to select a user/profile.

That is done by this line

objMessage.Recipients = objSession.AddressBook(OneAddress:=True)
What i want to be able to do is be able to tell which profile / name to load.
I have tried on various other websites and Google but nothing that instantly jumps out at me and says 'Put name/profile' name here.

So if you could take a look, and possibly help me figure out what i need to do to do this. Either by a simple line of code. Or by taking control of the window its self and adding data in and submitting the popup.

Many thanks for any help in advance.

Also posted on: http://www.xtremevbtalk.com/showthread.php?t=289552
But got no answer from these guys :(


Similar Threads
Thread Thread Starter Forum Replies Last Post
MAPI question - need help rlorenco Visual C++ 2005 0 March 7th, 2008 06:24 AM
CDO email BananaJim Classic ASP Professional 6 January 27th, 2007 08:04 PM
Troubles using MAPI email in VB6 mwphillips Pro VB 6 1 August 12th, 2003 01:29 AM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.