Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

C# & Email ....We want to send Email from my Application build in C#

Status
Not open for further replies.

vipuljpatel

Programmer
Aug 25, 2003
1
IN
HI ALL,

We need help on the following in C#.

We want to send Email from my Application build in C#. It should work both ways.

1. It should just create a mail in outlook express or Microsoft outlook with my parameters.

2. Also, it should send a mail directly without allowing the user to edit.



We tried some thing like this.



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

MailMessage msg = new MailMessage();

msg.From = "me@my.mail.server";

msg.To = "you@your.mail.server";

msg.Subject = "how to send mail using VC#.NET";

msg.Body = "this is the answer";

msg.BodyFormat = MailFormat.Text // can be MailFormat.HTML



SmtpMail.SmtpServer = "smtp.yours"; //assign smtp server here

SmtpMail.Send(msg); //this line actually fire the msg out

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


But this did not work.

If We set "SmtpServer" with my smtp server name, error is generated. "Could not access 'CDO.Message' object ". And if We do not give the "SmtpServer" (use default) then the error is not generated but no mail is sent. What are We doing wrong here. please suggest.


Also, Can anyone suggest us a component/product available free or otherwise that We can use for this purpose. We have seen some at google search but am confused. Please make your sugesstions basd on your experiences.



TIA,


Regards,

Vipul
 
The SmtpServer must be set to a valid Smtp Mail Server. If you did set this property to a valid server and have physical access to the server, check the mailqueue - the test e-mails that you have been attempting to send out may be hanging.

Also, the Mail object has no relation to Outlook. If you need to send mail using the Outlook object as you have stated, look into using the Microsoft Outlook COM object.

If all you want to do is send an e-mail out, don't bother buying a component. You will more than likely have to set the SmtpServer property for these anyways.

-----------------------------------------------
"The night sky over the planet Krikkit is the least interesting sight in the entire universe."
-Hitch Hiker's Guide To The Galaxy
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top