Recipient.Address in Exchange Server

J

Joel

TIA:

In earlier email I have following code:

Sub Send_Attachment_Messages()

Dim oFolder As Outlook.MAPIFolder
Dim Items As Outlook.Items
Dim objItem As MailItem
Dim Recips As Recipients
Dim Recip As Recipient

Set Items =
Application.GetNamespace("MAPI").GetDefaultFolder(olFolderOutbox).Items
For Each objItem In Items
Set Recips = objItem.Recipients
For Each Recip In Recips

If Recip.Address = "(e-mail address removed)" Then
objItem.Attachments.Add ("C:\copper\115.xls")
objItem.Send

ElseIf Recip.Address = "(e-mail address removed)" Then
objItem.Attachments.Add ("C:\copper\116.xls")
objItem.Send

ElseIf Recip.Address = "(e-mail address removed)" Then
objItem.Attachments.Add ("C:\copper\118.xls")
objItem.Send


End If
Next
Next
End Sub

When I run code in Outlook on non Exchange Server compute all is fine.

When I run code in Outlook that is networked with Excange Server, it doen't.
Upon debug the Reciepient.Address value is something like
"/o=Company/ou/SUBCOMPANY/cn=Main Office=JonesB" certainly not (e-mail address removed).
When I type the value as "o/=Company..." in the If test in my code, it still
doen't match the actual emails and thus nothing gets attached.

One other fact..the email is generated from Word Mail Merge. I can see the
values of EMail used by Word which is consistent with the data above
"o/Company..." but in Step Mode of Outlook Recip.Address appears as CAPS but
it is not that way in the Word Merge Data Table.

Any ideas of what my code needs to be to match the EMail address as seen in
the Outbox by my code. ie Recip.Address = "/o=Company/ou/SUBCOMPANY/cn=Main
Office=JonesB" doen't work even though this is the value shown in Step Mode.

Thanks very much,

Joel
 
D

Dmitry Streblechenko

Well, if the comparison fails, you can output the values, e.g. using MsgBox,
right?
First of all, e-mail adddress comparison should be cause insensitive.
Secondly, what you are seeing is a perfectly valid EX type (as opposed to
SMTP) address.

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top