Ureader.com  
Microsoft software help and Community
   home   |   control panel login   |   archive   |  
 
Exchange
2000.active.directory
2000.admin
2000.announcements
2000.app.conversion
2000.applications
2000.clients
2000.clustering
2000.connectivity
2000.development
2000.documentation
2000.general
2000.information.store
2000.interop
2000.kms
2000.misc
2000.protocols
2000.realtime.collabo.
2000.setup
2000.transport
2000.win2000
admin
application.conversion
applications
clients
clustering
connectivity
design
development
misc
mobility
setup
tools
  
 
date: Thu, 22 Feb 2007 16:54:00 -0800,    group: microsoft.public.exchange.development        back       


Help on MailItems and AD addresses   
In C#/.NET 2.0: How can I reply to an Email address retrieved from an 
Exchange server MailItem?

I am using Interop Outlook.MAPIFolder to retrieve Outlook.MailItem's.  I 
want to send an automated response to the sender of each MailItem, but 
MailItem.SenderEmailAddress is something like "/O=COMPANY/OU=ADMIN 
GROUP/CN=RECIPIENTS/CN=USERNAME".  I don't know what that is, though I 
assume it has something to do with active directory.

I can send messages using SMTP addresses in my current environment.  Is 
there a straightforward way to retrieve the SMTP address for an Exchange user 
in a situation like this?

MailItem also exposes a tempting public method "Reply()", which produces 
another MailItem object with a method "Send()", but when I call it I get an 
exception trying to cast the Reply to a MailItem.  Can anyone offer a working 
example of how to reply using MailItems?
date: Thu, 22 Feb 2007 16:54:00 -0800   author:   Dave Booker am

Re: Help on MailItems and AD addresses   
This is a normal EX type address. How exactly are you sending messages? If 
you have the EX provider in your current profile, using an EX address should 
not pose any problems.
If you are using Outlook 2007, you can use ExchangeUser.PrimarySmtpAddress 
property.

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

"Dave Booker" <dbooksta@newsgroup.nospam> wrote in message 
news:79C54BFC-7B95-40CC-B64D-8EBC6694DC8F@microsoft.com...
> In C#/.NET 2.0: How can I reply to an Email address retrieved from an
> Exchange server MailItem?
>
> I am using Interop Outlook.MAPIFolder to retrieve Outlook.MailItem's.  I
> want to send an automated response to the sender of each MailItem, but
> MailItem.SenderEmailAddress is something like "/O=COMPANY/OU=ADMIN
> GROUP/CN=RECIPIENTS/CN=USERNAME".  I don't know what that is, though I
> assume it has something to do with active directory.
>
> I can send messages using SMTP addresses in my current environment.  Is
> there a straightforward way to retrieve the SMTP address for an Exchange 
> user
> in a situation like this?
>
> MailItem also exposes a tempting public method "Reply()", which produces
> another MailItem object with a method "Send()", but when I call it I get 
> an
> exception trying to cast the Reply to a MailItem.  Can anyone offer a 
> working
> example of how to reply using MailItems?
>
date: Fri, 23 Feb 2007 08:56:03 -0700   author:   Dmitry Streblechenko

Re: Help on MailItems and AD addresses   
I'm used to sending messages using System.Net.Mail.SmtpClient.  (This is my 
first foray into Exchange Server.)  We're still using Office 2003.

If there's a straightforward way for me to send Emails to an EX address 
using C# that would meet my needs.  Can you point me to docs or exampels?

Also can you point me to documentation on the construction and validation of 
EX addresses?


"Dmitry Streblechenko" wrote:

> This is a normal EX type address. How exactly are you sending messages? If 
> you have the EX provider in your current profile, using an EX address should 
> not pose any problems.
> If you are using Outlook 2007, you can use ExchangeUser.PrimarySmtpAddress 
> property.
> 
> Dmitry Streblechenko (MVP)
> http://www.dimastr.com/
> OutlookSpy  - Outlook, CDO
> and MAPI Developer Tool
> 
> "Dave Booker" <dbooksta@newsgroup.nospam> wrote in message 
> news:79C54BFC-7B95-40CC-B64D-8EBC6694DC8F@microsoft.com...
> > In C#/.NET 2.0: How can I reply to an Email address retrieved from an
> > Exchange server MailItem?
> >
> > I am using Interop Outlook.MAPIFolder to retrieve Outlook.MailItem's.  I
> > want to send an automated response to the sender of each MailItem, but
> > MailItem.SenderEmailAddress is something like "/O=COMPANY/OU=ADMIN
> > GROUP/CN=RECIPIENTS/CN=USERNAME".  I don't know what that is, though I
> > assume it has something to do with active directory.
> >
> > I can send messages using SMTP addresses in my current environment.  Is
> > there a straightforward way to retrieve the SMTP address for an Exchange 
> > user
> > in a situation like this?
> >
> > MailItem also exposes a tempting public method "Reply()", which produces
> > another MailItem object with a method "Send()", but when I call it I get 
> > an
> > exception trying to cast the Reply to a MailItem.  Can anyone offer a 
> > working
> > example of how to reply using MailItems?
> > 
> 
> 
>
date: Fri, 23 Feb 2007 08:16:18 -0800   author:   Dave Booker am

Re: Help on MailItems and AD addresses   
If you are sending to an EX address, you obviously need to do that through 
the Exchange provider - anything based on Extended MAPI (that includes 
Outlook Object Model and CDO 1.21) will let you do that.
If you are retrieving the address through OOM, why not use OOM to send the 
message?
If you absolutely need to send through SMTP, you can retrieve the SMTP proxy 
addresses using Extended MAPI (C++/Dephi only), CDO 1.21 or <plug> 
Redemption (which also exposes the AddressEntry.SmtpAddress for all address 
entries on all version of Outlook) </plug>: essentially you will need to 
retrieve PR_EMS_AB_PROXY_ADDRESSES multivalued property with all proxy 
addresses for for the given EX address entry.

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

"Dave Booker" <dbooksta@newsgroup.nospam> wrote in message 
news:39A8702B-6F43-4744-8865-06D815DD8CB8@microsoft.com...
> I'm used to sending messages using System.Net.Mail.SmtpClient.  (This is 
> my
> first foray into Exchange Server.)  We're still using Office 2003.
>
> If there's a straightforward way for me to send Emails to an EX address
> using C# that would meet my needs.  Can you point me to docs or exampels?
>
> Also can you point me to documentation on the construction and validation 
> of
> EX addresses?
>
>
> "Dmitry Streblechenko" wrote:
>
>> This is a normal EX type address. How exactly are you sending messages? 
>> If
>> you have the EX provider in your current profile, using an EX address 
>> should
>> not pose any problems.
>> If you are using Outlook 2007, you can use 
>> ExchangeUser.PrimarySmtpAddress
>> property.
>>
>> Dmitry Streblechenko (MVP)
>> http://www.dimastr.com/
>> OutlookSpy  - Outlook, CDO
>> and MAPI Developer Tool
>>
>> "Dave Booker" <dbooksta@newsgroup.nospam> wrote in message
>> news:79C54BFC-7B95-40CC-B64D-8EBC6694DC8F@microsoft.com...
>> > In C#/.NET 2.0: How can I reply to an Email address retrieved from an
>> > Exchange server MailItem?
>> >
>> > I am using Interop Outlook.MAPIFolder to retrieve Outlook.MailItem's. 
>> > I
>> > want to send an automated response to the sender of each MailItem, but
>> > MailItem.SenderEmailAddress is something like "/O=COMPANY/OU=ADMIN
>> > GROUP/CN=RECIPIENTS/CN=USERNAME".  I don't know what that is, though I
>> > assume it has something to do with active directory.
>> >
>> > I can send messages using SMTP addresses in my current environment.  Is
>> > there a straightforward way to retrieve the SMTP address for an 
>> > Exchange
>> > user
>> > in a situation like this?
>> >
>> > MailItem also exposes a tempting public method "Reply()", which 
>> > produces
>> > another MailItem object with a method "Send()", but when I call it I 
>> > get
>> > an
>> > exception trying to cast the Reply to a MailItem.  Can anyone offer a
>> > working
>> > example of how to reply using MailItems?
>> >
>>
>>
>>
date: Fri, 23 Feb 2007 13:08:44 -0700   author:   Dmitry Streblechenko

RE: Help on MailItems and AD addresses   
Once you have this "/O=COMPANY/OU=ADMIN GROUP/CN=RECIPIENTS/CN=USERNAME" 
address 90% of the battle is over.

That's AD-speak for who the recipient is.  If you want to send to that 
address via System.Net.Mail, you can query AD for the actual email address 
and use that:

make sure you include System.DirectoryServices; (requires a .NET added 
reference)

DirectoryEntry de = new 
DirectoryEntry("LDAP://[domain.com]/[O=COMPANY/OU=ADMIN 
GROUP/CN=RECIPIENTS/CN=USERNAME]", 
@"[domain\username]", "[password]");
[in the above, replace bracketed parts with your domain 
information/credentials]
Then, there is probably a better way to get the email from here, but this is 
a way that's worked for me:
DirectorySearcher ds = new DirectorySearcher();
ds.SearchRoot = de;
ds.Filter = "(SAMAccountName=*)"; //query for all aliases (SAMAccountName) 
matching this "AD address"
ds.SearchScope = SearchScope.SubTree;

//simplistic results w/o error checking
SearchResult sr = ds.FindOne();
string alias= sr.Properties["SAMAccountName"][0]; //need to handle nulls/0 
results/multiple results here
you can youse Properties["mail"] if you want the full email address and not 
just the alias for alias@[domain.com].

Then you can send to it like normal

If you need more help you can try the System.DirectoryServices 
documentation.  Make sure your LDAP is in upper case.

"Dave Booker" wrote:

> In C#/.NET 2.0: How can I reply to an Email address retrieved from an 
> Exchange server MailItem?
> 
> I am using Interop Outlook.MAPIFolder to retrieve Outlook.MailItem's.  I 
> want to send an automated response to the sender of each MailItem, but 
> MailItem.SenderEmailAddress is something like "/O=COMPANY/OU=ADMIN 
> GROUP/CN=RECIPIENTS/CN=USERNAME".  I don't know what that is, though I 
> assume it has something to do with active directory.
> 
> I can send messages using SMTP addresses in my current environment.  Is 
> there a straightforward way to retrieve the SMTP address for an Exchange user 
> in a situation like this?
> 
> MailItem also exposes a tempting public method "Reply()", which produces 
> another MailItem object with a method "Send()", but when I call it I get an 
> exception trying to cast the Reply to a MailItem.  Can anyone offer a working 
> example of how to reply using MailItems?
>
date: Sat, 24 Feb 2007 09:46:00 -0800   author:   Chad

Re: Help on MailItems and AD addresses   
Hello,

actually, the address you get here is an Exchange legacy distinguished name, 
used by Exchangg 5.5. Since Active Directory uses normal distinguished 
names, you can not use the legacyExchangeDN to bind to the object.

You must perform an LDAP search to get the object:

DirectoryEntry entry = new DirectoryEntry("dc", "username", "password", 
AuthenticationTypes.Secure);
DirectorySearcher searcher = new DirectorySearcher(entry, 
"(legacyExchangeDN=/O=COMPANY/OU=ADMIN GROUP/CN=RECIPIENTS/CN=USERNAME)");
SearchResult sr = searcher.FindOne();
if (sr == null)
{
    // User not found
}
else
{
    // User found
}

Substitute the "dc" with something like this: LDAP://[domain.com]/DC=Domain, 
DC=com.

If your Active Directory spans more than one domain, you're probably better 
of using GC://[domain.com]/DC=Domain, DC=com, where "DC=Domain, DC=COM" 
should be the distinguished name of the Root domain. This will perform a 
search on a Global Catalog server, which contains information about all 
objects in a forest.

Note that you can omit the [domain.com] completely, if the computer you are 
using is in the domain.

Best regards,
Henning Krause



"Chad"  wrote in message 
news:ED931658-5495-42AE-865A-F17B079D027A@microsoft.com...
> Once you have this "/O=COMPANY/OU=ADMIN GROUP/CN=RECIPIENTS/CN=USERNAME"
> address 90% of the battle is over.
>
> That's AD-speak for who the recipient is.  If you want to send to that
> address via System.Net.Mail, you can query AD for the actual email address
> and use that:
>
> make sure you include System.DirectoryServices; (requires a .NET added
> reference)
>
> DirectoryEntry de = new
> DirectoryEntry("LDAP://[domain.com]/[O=COMPANY/OU=ADMIN
> GROUP/CN=RECIPIENTS/CN=USERNAME]",
> @"[domain\username]", "[password]");
> [in the above, replace bracketed parts with your domain
> information/credentials]
> Then, there is probably a better way to get the email from here, but this 
> is
> a way that's worked for me:
> DirectorySearcher ds = new DirectorySearcher();
> ds.SearchRoot = de;
> ds.Filter = "(SAMAccountName=*)"; //query for all aliases (SAMAccountName)
> matching this "AD address"
> ds.SearchScope = SearchScope.SubTree;
>
> //simplistic results w/o error checking
> SearchResult sr = ds.FindOne();
> string alias= sr.Properties["SAMAccountName"][0]; //need to handle nulls/0
> results/multiple results here
> you can youse Properties["mail"] if you want the full email address and 
> not
> just the alias for alias@[domain.com].
>
> Then you can send to it like normal
>
> If you need more help you can try the System.DirectoryServices
> documentation.  Make sure your LDAP is in upper case.
>
> "Dave Booker" wrote:
>
>> In C#/.NET 2.0: How can I reply to an Email address retrieved from an
>> Exchange server MailItem?
>>
>> I am using Interop Outlook.MAPIFolder to retrieve Outlook.MailItem's.  I
>> want to send an automated response to the sender of each MailItem, but
>> MailItem.SenderEmailAddress is something like "/O=COMPANY/OU=ADMIN
>> GROUP/CN=RECIPIENTS/CN=USERNAME".  I don't know what that is, though I
>> assume it has something to do with active directory.
>>
>> I can send messages using SMTP addresses in my current environment.  Is
>> there a straightforward way to retrieve the SMTP address for an Exchange 
>> user
>> in a situation like this?
>>
>> MailItem also exposes a tempting public method "Reply()", which produces
>> another MailItem object with a method "Send()", but when I call it I get 
>> an
>> exception trying to cast the Reply to a MailItem.  Can anyone offer a 
>> working
>> example of how to reply using MailItems?
>>
date: Sun, 25 Feb 2007 14:11:03 +0100   author:   Henning Krause [MVP - Exchange]

Google
 
Web ureader.com


    COPYRIGHT 2007, YARDI TECHNOLOGY LIMITED, ALL RIGHT RESERVE  |   contact us