Dim Msg as MailMessage = new MailMessage()
Dim MailObj As New SmtpClient("mail.e-crs.com")
Msg.To.add = "register@dotnet.itags.org.e-crs.com"
Msg.From.email = "register@dotnet.itags.org.e-crs.com"
Msg.Subject="Sales Agent Registration Information"
Msg.Body=sMsg
Msg.IsBodyHtml = "False"
MailObj.SmtpServer ="mail.e-crs.com"
MailObj.Send(Msg)
I know there are mistakes in the code above any help would be great.
Here is a C# function to send mail that works. Maybe it will give you ideas if your isin't working.Hope it helps,
Joe
public static void SendEmail(
string from,
string to,
string cc,
string bcc,
string subject,
string messageBody,
bool html,
string priority)
{
MailMessage mail = new System.Web.Mail.MailMessage();
mail.From =from;
mail.To = to;
if(cc.Length > 0)
{
mail.Cc = cc;
}
if(bcc.Length > 0)
{
mail.Bcc = bcc;
}
mail.Subject = subject;
switch(priority)
{
case "High":
mail.Priority = MailPriority.High;
break;
case "Low":
mail.Priority = MailPriority.Low;
break;
case "Normal":
default:
mail.Priority = MailPriority.Normal;
break;
}
if(ConfigurationSettings.AppSettings.Get("SMTPRequiresAuthentication").ToLower() == "true")
{
mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", SMTP_AUTHENTICATED);
mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername",ConfigurationSettings.AppSettings.Get("SMTPUser") );
mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword", ConfigurationSettings.AppSettings.Get("SMTPPassword"));
}
mail.Body = messageBody;
if(html)
{
mail.BodyFormat = MailFormat.Html;
}
else
{
mail.BodyFormat = MailFormat.Text;
}
SmtpMail.SmtpServer = ConfigurationSettings.AppSettings.Get("SMTPServer");
SmtpMail.Send(mail);
}
Hi,
Have a look at these 2 sites. You will have all the information needed to send mails
Sending Mail with .Net 1.1
Sending Mail with .Net 2.0
Thanks
0 comments:
Post a Comment