By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
425,925 Members | 732 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 425,925 IT Pros & Developers. It's quick & easy.

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

P: n/a
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
Share this Question
Share on Google+
3 Replies


P: n/a
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

P: n/a
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

P: n/a
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.