Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Visual Basic > VB 2005 > Pro Visual Basic 2005
Password Reminder
Register
| FAQ | Members List | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
 
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old November 1st, 2007, 05:49 AM
Registered User
 
Join Date: Nov 2007
Location: , , .
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default CDO - MAPI - Email - AddressBook Access Question

Hello

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

Code:
Imports Microsoft.Office.Interop

Module Module1

    Const CdoPR_EMS_AB_PROXY_ADDRESSES = &H800F101E

    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")
        objSession.Logon("Outlook")

        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 = _
           objRecip.AddressEntry.Fields(CdoPR_EMS_AB_PROXY_ADDRESSES)

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

        objSession.Logoff()

    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

Name
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

Code:
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 :(

Kev

 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


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



All times are GMT -4. The time now is 03:41 PM.


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