Exchange Sending Mail

G

Guest

Hi all

I am currently trying to send and email via exchange except I'm having a
nightmare getting it working, you'd think this would be pertty simple
wouldn't you?

I have added a reference to cdoex.dll in my project and this is my code:


ADODB.ConnectionClass conn = null;
CDO.MessageClass msg = new CDO.MessageClass();C
CDO.ConfigurationClass config = new CDO.ConfigurationClass();
conn = new ADODB.ConnectionClass();
conn.Provider = "MSDAIPP.DSO.1";
conn.Open("http://servername/exchange/mailboxname", "username", "password",
-1);
config.Fields[CDO.CdoConfiguration.cdoSendUserReplyEmailAddress].Value =
(e-mail address removed);
config.Fields[CDO.CdoConfiguration.cdoSendEmailAddress].Value =
(e-mail address removed);
config.Fields[CDO.CdoConfiguration.cdoSendUserName].Value = "username";
config.Fields[CDO.CdoConfiguration.cdoSendPassword].Value = "password";
config.Fields[CDO.CdoConfiguration.cdoSendUsingMethod].Value =
CDO.CdoSendUsing.cdoSendUsingExchange;
config.Fields[CDO.CdoConfiguration.cdoMailboxURL].Value =
"http://servername/exchange/mailboxname";
config.Fields[CDO.CdoConfiguration.cdoActiveConnection].Value = conn;
config.Fields.Update();

msg.Configuration = config;
msg.To = (e-mail address removed);
msg.Subject = "tester";
msg.TextBody = "saf";
msg.Send();

When I run this code i receive an "Unspecified Error" which of course helps
no end in solving the issue.

Anyone any ideas or code snippets they would like to share with me about
sending mails with attachments via an exchange account.
 
G

Guest

I want the mail to drop into the sent items of a certain users mailbox, hence
the reason for sending via exchange and not just smtp.
--
It''''''''s all fun and games until someone loses an eye, then it''''''''s
just fun and games that you can''''''''t see!


Ollie Riches said:
Why not just use System.Web.Mail namespace to send mail to the exchange
server?

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemwebmail.asp

HTH

Ollie Riches

Gaz said:
Hi all

I am currently trying to send and email via exchange except I'm having a
nightmare getting it working, you'd think this would be pertty simple
wouldn't you?

I have added a reference to cdoex.dll in my project and this is my code:


ADODB.ConnectionClass conn = null;
CDO.MessageClass msg = new CDO.MessageClass();C
CDO.ConfigurationClass config = new CDO.ConfigurationClass();
conn = new ADODB.ConnectionClass();
conn.Provider = "MSDAIPP.DSO.1";
conn.Open("http://servername/exchange/mailboxname", "username",
"password",
-1);
config.Fields[CDO.CdoConfiguration.cdoSendUserReplyEmailAddress].Value =
(e-mail address removed);
config.Fields[CDO.CdoConfiguration.cdoSendEmailAddress].Value =
(e-mail address removed);
config.Fields[CDO.CdoConfiguration.cdoSendUserName].Value = "username";
config.Fields[CDO.CdoConfiguration.cdoSendPassword].Value = "password";
config.Fields[CDO.CdoConfiguration.cdoSendUsingMethod].Value =
CDO.CdoSendUsing.cdoSendUsingExchange;
config.Fields[CDO.CdoConfiguration.cdoMailboxURL].Value =
"http://servername/exchange/mailboxname";
config.Fields[CDO.CdoConfiguration.cdoActiveConnection].Value = conn;
config.Fields.Update();

msg.Configuration = config;
msg.To = (e-mail address removed);
msg.Subject = "tester";
msg.TextBody = "saf";
msg.Send();

When I run this code i receive an "Unspecified Error" which of course
helps
no end in solving the issue.

Anyone any ideas or code snippets they would like to share with me about
sending mails with attachments via an exchange account.
 
Top