I need to know how to send mail using C#. I have a class that will be throwing parameters (see below):
private
void SendToAnalyst(){
string emailSubject = string.Empty; string emailAddress = string.Empty;StringBuilder sb =
new StringBuilder(); //To Do: Instantiate Monitoring Component if(mSourceSystem.ToUpper().Equals("FLEXCAB")){
emailSubject = "Sample RequestId (FLEXCAB To RADTI RESPONSE): "+mSampleRequestID;
sb.Append("**************************************************************************************\n");
sb.Append("\n");
sb.Append("Please do not reply to this email. This is a System generated email.\n");
sb.Append("\n");
sb.Append("**************************************************************************************\n");
sb.Append("\n");
sb.Append("Sample Request ID: "+mSampleRequestID+"\n");
sb.Append("Request Status: "+ mReqStatus+"\n");
sb.Append("\n");
sb.Append("Please Correct the error and re-submit.\n");
sb.Append("Or Call the EDS DBA on 03-8866-7424\n");
//Console.WriteLine(sb.ToString()); // Send the email body to Monitoring component}
}
The send mail class I am trying to create should catch the parameters from this SendToAnalyst class.

Sending mail with C#
jennie44752
I need to understand how to specify this too. Did you ever get an answer
Eyes
It looks like the original poster was in a corporate environment, so it would be easy to get this information, while it is a bit more difficult for the hobbyist using free email providers.
Cosmin Paun
Hi nicpn,
this code snippet should get you started:
using System.Web.Mail;
MailMessage msg = new MailMessage();
msg.To = emailAddress;
msg.From = "yourAddress@domain"
msg.Subject = emailSubject;
msg.Body = sb.ToString();
SmtpMail.SmtpServer = "TheNameOrAddressOfYourMailServer";
SmtpMail.Send(msg);
HTH,
SvenC
Tiago_mor
How can I know the name or address of my smtp server. I assume that my e-mail is user@yahoo.com. Where can I find the smtp name and port connection for that.
I have been checking the System.Web.Net namespace, and it requieres to have a a port conecction for the smpt client in order to get use the relative object. The above namespace is the new one used in c# 2005 beta 2 to send e-mails.
Thanks...
Adolfo