access denied to CDO.Message

G

Guest

Hi,

I have developed a windows application for our client, which informs
passengers thru email regarding a schedule change of flights. When i tested
it at my end, using their SMTP server, the mails were being sent but when
application was installed at client's place, using the same SMTP server,
mails are not being sent. I'm getting an error message -

System.Web.HttpException: Could not access 'CDO.Message' object. --->
System.Reflection.TargetInvocationException: Exception has been thrown by the
target of an invocation. ---> System.Runtime.InteropServices.COMException
(0x80040220): The "SendUsing" configuration value is invalid.


My code -

-----------------*******************--------------------------

SmtpMail.SmtpServer.Insert(0,["SMTP_Server_Name"]);
MailMessage mailMessage = new MailMessage();
mailMessage.BodyFormat = MailFormat.Html ;
mailMessage.From = fromEmailId;
mailMessage.To = toEmailId;
mailMessage.Subject = subject;
mailMessage.Body = body;

mailMessage.Headers.Add("Reply-To",reply_to);

mailMessage.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout", 60);

mailMessage.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", "1");

mailMessage.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername", username);

mailMessage.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword", pwd);

SmtpMail.Send(mailMessage);

-----------------*******************--------------------------

Please help me out with this. It's urgent.

Thanks and Regards,
Pooja.
 
G

Guest

Your first line of code looks weird. SmtpMail.SmtpServer is just a string so
I really do not know what you are trying to do. Your code results in an
empty string for SmtpMail.SmtpServer, so it will try to send the mail using
the local SMTP server. Change the code to:

SmtpMail.SmtpServer = smtpServerName;

HTH, Jakob.
 
G

Guest

Hi,

Thanx for replying. Actually i'm reading SMTP Server Name from the
configuration settings in the first line of my code. Just changed that line
while copy pasting here. Originally it looks like -

SmtpMail.SmtpServer.Insert(0,System.Configuration.ConfigurationSettings.AppSettings["SMTP_Server_Name"]);

Please help me now.

Thanks and Regards,
Pooja.

Jakob Christensen said:
Your first line of code looks weird. SmtpMail.SmtpServer is just a string so
I really do not know what you are trying to do. Your code results in an
empty string for SmtpMail.SmtpServer, so it will try to send the mail using
the local SMTP server. Change the code to:

SmtpMail.SmtpServer = smtpServerName;

HTH, Jakob.


Pooja said:
Hi,

I have developed a windows application for our client, which informs
passengers thru email regarding a schedule change of flights. When i tested
it at my end, using their SMTP server, the mails were being sent but when
application was installed at client's place, using the same SMTP server,
mails are not being sent. I'm getting an error message -

System.Web.HttpException: Could not access 'CDO.Message' object. --->
System.Reflection.TargetInvocationException: Exception has been thrown by the
target of an invocation. ---> System.Runtime.InteropServices.COMException
(0x80040220): The "SendUsing" configuration value is invalid.


My code -

-----------------*******************--------------------------

SmtpMail.SmtpServer.Insert(0,["SMTP_Server_Name"]);
MailMessage mailMessage = new MailMessage();
mailMessage.BodyFormat = MailFormat.Html ;
mailMessage.From = fromEmailId;
mailMessage.To = toEmailId;
mailMessage.Subject = subject;
mailMessage.Body = body;

mailMessage.Headers.Add("Reply-To",reply_to);

mailMessage.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout", 60);

mailMessage.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", "1");

mailMessage.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername", username);

mailMessage.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword", pwd);

SmtpMail.Send(mailMessage);

-----------------*******************--------------------------

Please help me out with this. It's urgent.

Thanks and Regards,
Pooja.
 
G

Guest

My point is that the following code will set SmtpMail.SmtpServer to the empty
string (hence it will use the local smtp server):

SmtpMail.SmtpServer.Insert(0,
System.Configuration.ConfigurationSettings.AppSettings["SMTP_Server_Name"]);

Instead you should use:

SmtpMail.SmtpServer =
System.Configuration.ConfigurationSettings.AppSettings["SMTP_Server_Name"];

Regards, Jakob.


Pooja said:
Hi,

Thanx for replying. Actually i'm reading SMTP Server Name from the
configuration settings in the first line of my code. Just changed that line
while copy pasting here. Originally it looks like -

SmtpMail.SmtpServer.Insert(0,System.Configuration.ConfigurationSettings.AppSettings["SMTP_Server_Name"]);

Please help me now.

Thanks and Regards,
Pooja.

Jakob Christensen said:
Your first line of code looks weird. SmtpMail.SmtpServer is just a string so
I really do not know what you are trying to do. Your code results in an
empty string for SmtpMail.SmtpServer, so it will try to send the mail using
the local SMTP server. Change the code to:

SmtpMail.SmtpServer = smtpServerName;

HTH, Jakob.


Pooja said:
Hi,

I have developed a windows application for our client, which informs
passengers thru email regarding a schedule change of flights. When i tested
it at my end, using their SMTP server, the mails were being sent but when
application was installed at client's place, using the same SMTP server,
mails are not being sent. I'm getting an error message -

System.Web.HttpException: Could not access 'CDO.Message' object. --->
System.Reflection.TargetInvocationException: Exception has been thrown by the
target of an invocation. ---> System.Runtime.InteropServices.COMException
(0x80040220): The "SendUsing" configuration value is invalid.


My code -

-----------------*******************--------------------------

SmtpMail.SmtpServer.Insert(0,["SMTP_Server_Name"]);
MailMessage mailMessage = new MailMessage();
mailMessage.BodyFormat = MailFormat.Html ;
mailMessage.From = fromEmailId;
mailMessage.To = toEmailId;
mailMessage.Subject = subject;
mailMessage.Body = body;

mailMessage.Headers.Add("Reply-To",reply_to);

mailMessage.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout", 60);

mailMessage.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", "1");

mailMessage.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername", username);

mailMessage.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword", pwd);

SmtpMail.Send(mailMessage);

-----------------*******************--------------------------

Please help me out with this. It's urgent.

Thanks and Regards,
Pooja.
 
G

Guest

Hi,

It's still giving the same error. Do you think that on the machine from
where mail is being sent, Dafault SMTP Virtaul Server needs to be configured?

Thanks and Regards,
Pooja.

Jakob Christensen said:
My point is that the following code will set SmtpMail.SmtpServer to the empty
string (hence it will use the local smtp server):

SmtpMail.SmtpServer.Insert(0,
System.Configuration.ConfigurationSettings.AppSettings["SMTP_Server_Name"]);

Instead you should use:

SmtpMail.SmtpServer =
System.Configuration.ConfigurationSettings.AppSettings["SMTP_Server_Name"];

Regards, Jakob.


Pooja said:
Hi,

Thanx for replying. Actually i'm reading SMTP Server Name from the
configuration settings in the first line of my code. Just changed that line
while copy pasting here. Originally it looks like -

SmtpMail.SmtpServer.Insert(0,System.Configuration.ConfigurationSettings.AppSettings["SMTP_Server_Name"]);

Please help me now.

Thanks and Regards,
Pooja.

Jakob Christensen said:
Your first line of code looks weird. SmtpMail.SmtpServer is just a string so
I really do not know what you are trying to do. Your code results in an
empty string for SmtpMail.SmtpServer, so it will try to send the mail using
the local SMTP server. Change the code to:

SmtpMail.SmtpServer = smtpServerName;

HTH, Jakob.


:

Hi,

I have developed a windows application for our client, which informs
passengers thru email regarding a schedule change of flights. When i tested
it at my end, using their SMTP server, the mails were being sent but when
application was installed at client's place, using the same SMTP server,
mails are not being sent. I'm getting an error message -

System.Web.HttpException: Could not access 'CDO.Message' object. --->
System.Reflection.TargetInvocationException: Exception has been thrown by the
target of an invocation. ---> System.Runtime.InteropServices.COMException
(0x80040220): The "SendUsing" configuration value is invalid.


My code -

-----------------*******************--------------------------

SmtpMail.SmtpServer.Insert(0,["SMTP_Server_Name"]);
MailMessage mailMessage = new MailMessage();
mailMessage.BodyFormat = MailFormat.Html ;
mailMessage.From = fromEmailId;
mailMessage.To = toEmailId;
mailMessage.Subject = subject;
mailMessage.Body = body;

mailMessage.Headers.Add("Reply-To",reply_to);

mailMessage.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout", 60);

mailMessage.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", "1");

mailMessage.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername", username);

mailMessage.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword", pwd);

SmtpMail.Send(mailMessage);

-----------------*******************--------------------------

Please help me out with this. It's urgent.

Thanks and Regards,
Pooja.
 
G

Guest

Every time I seen this message it is because the message body wasn't conform
with the SMTP specifications. Even if it doesn't seem to be that I suggest to
look around that for exemples the carriage returns...

Joel Descombes
 
S

Sreejath S. Warrier

Hello Pooja,
just guessing here. I see that you are reading the SMTP Server name from
the config file.
While deploying, have you changed the server name to match the production
SMTP Server?
Regards,
Sreejath
Hi,

It's still giving the same error. Do you think that on the machine
from where mail is being sent, Dafault SMTP Virtaul Server needs to be
configured?

Thanks and Regards,
Pooja.
Jakob Christensen said:
My point is that the following code will set SmtpMail.SmtpServer to
the empty string (hence it will use the local smtp server):

SmtpMail.SmtpServer.Insert(0,
System.Configuration.ConfigurationSettings.AppSettings["SMTP_Server_N
ame"]);

Instead you should use:

SmtpMail.SmtpServer =
System.Configuration.ConfigurationSettings.AppSettings["SMTP_Server_N
ame"];

Regards, Jakob.

Pooja said:
Hi,

Thanx for replying. Actually i'm reading SMTP Server Name from the
configuration settings in the first line of my code. Just changed
that line while copy pasting here. Originally it looks like -

SmtpMail.SmtpServer.Insert(0,System.Configuration.ConfigurationSetti
ngs.AppSettings["SMTP_Server_Name"]);

Please help me now.

Thanks and Regards,
Pooja.
:

Your first line of code looks weird. SmtpMail.SmtpServer is just a
string so I really do not know what you are trying to do. Your
code results in an empty string for SmtpMail.SmtpServer, so it will
try to send the mail using the local SMTP server. Change the code
to:

SmtpMail.SmtpServer = smtpServerName;

HTH, Jakob.

:

Hi,

I have developed a windows application for our client, which
informs passengers thru email regarding a schedule change of
flights. When i tested it at my end, using their SMTP server, the
mails were being sent but when application was installed at
client's place, using the same SMTP server, mails are not being
sent. I'm getting an error message -

System.Web.HttpException: Could not access 'CDO.Message' object.
---> System.Reflection.TargetInvocationException: Exception has
been thrown by the target of an invocation. --->
System.Runtime.InteropServices.COMException (0x80040220): The
"SendUsing" configuration value is invalid.

My code -

-----------------*******************--------------------------

SmtpMail.SmtpServer.Insert(0,["SMTP_Server_Name"]);
MailMessage mailMessage = new MailMessage();
mailMessage.BodyFormat = MailFormat.Html ;
mailMessage.From = fromEmailId;
mailMessage.To = toEmailId;
mailMessage.Subject = subject;
mailMessage.Body = body;
mailMessage.Headers.Add("Reply-To",reply_to);

mailMessage.Fields.Add("http://schemas.microsoft.com/cdo/configura
tion/smtpconnectiontimeout", 60);

mailMessage.Fields.Add("http://schemas.microsoft.com/cdo/configura
tion/smtpauthenticate", "1");

mailMessage.Fields.Add("http://schemas.microsoft.com/cdo/configura
tion/sendusername", username);

mailMessage.Fields.Add("http://schemas.microsoft.com/cdo/configura
tion/sendpassword", pwd);

SmtpMail.Send(mailMessage);

-----------------*******************--------------------------

Please help me out with this. It's urgent.

Thanks and Regards,
Pooja.
 

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