470,586 Members | 1,334 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,586 developers. It's quick & easy.

System.Web.Mail.MailMessage.From property assignment problem

Hi has anyone come accross the problem....
with referance to System.Web.Mail.MailMessage and
System.Web.Mail.SmtpMail

THIS WORKS FINE
mail=new MailMessage();
mail.From = "W-MyPcName.mycompany.com";
mail.To=strTo;
mail.Cc=strCC;
mail.Bcc=strBCC;
mail.Subject = strSubject;
mail.Body = strBody;
THIS DOES NOT WORK ????
string machine = Environment.MachineName + ".mycompany.com";
mail=new MailMessage();
mail.From = machine ;
mail.To=strTo;
mail.Cc=strCC;
mail.Bcc=strBCC;
mail.Subject = strSubject;
mail.Body = strBody;

When you look at the the value in 'mail.From' on both of the above, the

EXACT same string is present.
Its got me, any help welcome :)

The error message is as follows:
Error source: System.Web
Message: Could not access 'CDO.Message' object.
Stack: at System.Web.Mail.LateBoundAccessHelper.CallMethod(O bject
obj, String
methodName, Object[] args)
at System.Web.Mail.CdoSysHelper.Send(MailMessage message)
at System.Web.Mail.SmtpMail.Send(MailMessage message)
at PCOMClassLibrary.SendMailMessage.SendMail() in
c:\dotnetwork\pcomclasslibr
ary\sendmailmessage.cs:line 101

Nov 17 '05 #1
3 3066
Phil,

This happens when you assign the value to the field, or when you try and
send? My guess is that the values are not actually the same.

The error you are showing indicates that you are having a problem when
sending the mail (not setting the value), and that it can't access the CDO
object. This leads me to believe that you do not have CDO or CDONT
installed on the machine you are trying to send mail from.

Quite honestly, I wouldn't recommend the mail classes in the
System.Web.Mail namespace (because of the CDO and SMTP requirements). If
you are using .NET 2.0, use the classes in the System.Net.Mail namespace or
if you are using .NET 1.1, use the classes in the Indy Project
(http://www.indyproject.org).

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Phil Mc" <ph**********@pramerica.ie> wrote in message
news:11*********************@g47g2000cwa.googlegro ups.com...
Hi has anyone come accross the problem....
with referance to System.Web.Mail.MailMessage and
System.Web.Mail.SmtpMail

THIS WORKS FINE
mail=new MailMessage();
mail.From = "W-MyPcName.mycompany.com";
mail.To=strTo;
mail.Cc=strCC;
mail.Bcc=strBCC;
mail.Subject = strSubject;
mail.Body = strBody;
THIS DOES NOT WORK ????
string machine = Environment.MachineName + ".mycompany.com";
mail=new MailMessage();
mail.From = machine ;
mail.To=strTo;
mail.Cc=strCC;
mail.Bcc=strBCC;
mail.Subject = strSubject;
mail.Body = strBody;

When you look at the the value in 'mail.From' on both of the above, the

EXACT same string is present.
Its got me, any help welcome :)

The error message is as follows:
Error source: System.Web
Message: Could not access 'CDO.Message' object.
Stack: at System.Web.Mail.LateBoundAccessHelper.CallMethod(O bject
obj, String
methodName, Object[] args)
at System.Web.Mail.CdoSysHelper.Send(MailMessage message)
at System.Web.Mail.SmtpMail.Send(MailMessage message)
at PCOMClassLibrary.SendMailMessage.SendMail() in
c:\dotnetwork\pcomclasslibr
ary\sendmailmessage.cs:line 101

Nov 17 '05 #2
Thanks for that Nicholas;
Unfortunately I am stuck with .NET 1.1 at present and cannot use the
third party classes you suggested. The frustrating this about this is
that when I inspect the two versions and get their respective hash
codes that are the same:
string machine = Environment.MachineName.ToString() +
".prudential.com".Trim();
int a1 = machine.GetHashCode();
int a2 = "W-I557425F.prudential.com".GetHashCode();
Looks like Ill have to go back and reinvent the wheel, and write my own
smpt class.

Thanks for your help.

Nov 17 '05 #3
Why can't you use the indy project libraries?

Also, you didn't address the other items I mentioned, about CDO and
SMTP, since the error you received was not from setting the property, but
from sending the message.

--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Phil Mc" <ph**********@pramerica.ie> wrote in message
news:11**********************@g49g2000cwa.googlegr oups.com...
Thanks for that Nicholas;
Unfortunately I am stuck with .NET 1.1 at present and cannot use the
third party classes you suggested. The frustrating this about this is
that when I inspect the two versions and get their respective hash
codes that are the same:
string machine = Environment.MachineName.ToString() +
".prudential.com".Trim();
int a1 = machine.GetHashCode();
int a2 = "W-I557425F.prudential.com".GetHashCode();
Looks like Ill have to go back and reinvent the wheel, and write my own
smpt class.

Thanks for your help.

Nov 17 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by Trond A. S. Andersen | last post: by
5 posts views Thread by martin | last post: by
8 posts views Thread by marcmc | last post: by
1 post views Thread by maflatoun | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.