我已經寫了從消息queue.My控制檯應用程序檢索數據和發送郵件的測試控制檯應用程序駐留在我的主要project.In我的消息相同 解決方案隊列位於messages.When我跑我的控制檯應用程序存在於 郵件發送方法的調用郵件,但問題是郵件沒有得到未得到應用,我在 web.config文件給mailSettings時sent.seenms我正在通過控制檯applications.Because發送郵件,當我直接發送郵件,而 控制檯應用程序的消息越來越發送successfully.Also當我通過SMTP郵件的屬性中指定的 源代碼本身郵件設置選項的幫助正在通過控制檯應用程序發送。但我想通過控制檯應用程序發送郵件 在web.congig上設置的郵件設置。錯誤上通過控制檯應用程序發送郵件asp.net
我怎樣才能解決這個問題。
此致敬禮。
我在web.config中設置。
我給發送郵件
公共靜態無效SendMailMessage(串從,字符串,字符串BCC,串立方厘米,字符串對象,串體,列表附件) 代碼//實例化MailMessage的新實例 MailMessage mMailMessage = new MailMessage();
// Set the sender address of the mail message
mMailMessage.From = new MailAddress(from);
// Set the recepient address of the mail message
//string[] arrEmailTo = to.Split(',');
//foreach (string itemTo in arrEmailTo)
//{
// //mMailMessage.To.Add(new MailAddress(itemTo));
//}
mMailMessage.To.Add(to);
// Check if the bcc value is null or an empty string
if ((bcc != null) && (bcc != string.Empty))
{
// Set the Bcc address of the mail message
mMailMessage.Bcc.Add(new MailAddress(bcc));
}
// Check if the cc value is null or an empty value
if ((cc != null) && (cc != string.Empty))
{
// Set the CC address of the mail message
mMailMessage.CC.Add(new MailAddress(cc));
}
// Set the subject of the mail message
mMailMessage.Subject = subject;
//mMailMessage.SubjectEncoding = System.Text.Encoding.UTF8;
//int Idd=BitConverter.ToInt32(Encrypt((Id.Id).ToString()),0);
// byte[] IdHash = Encrypt((Id.Id).ToString());//generating hassh value
//int IdHash1 = BitConverter.ToInt32(IdHash, 0);
//passing the hash value by encoding it
// Set the body of the mail message
mMailMessage.Body = body;
//include the attachments if any
if(attachments!=null)
foreach (string file in attachments)
{
Attachment aa = new Attachment(UpPath+file);
mMailMessage.Attachments.Add(aa);
}
// Secify the format of the body as HTML
mMailMessage.IsBodyHtml = true;
// Set the priority of the mail message to normal
mMailMessage.Priority = MailPriority.High;
// Instantiate a new instance of SmtpClient
SmtpClient mSmtpClient = new SmtpClient();
mSmtpClient.EnableSsl = true;
// ********* //使用這些選項在源代碼中設置的郵件是越來越精發送// ******
//mSmtpClient.Host = "smtp.gmail.com";
//mSmtpClient.Port = 25;
// Send the mail message
//System.Net.NetworkCredential s = new System.Net.NetworkCredential("[email protected]", "password");
//mSmtpClient.Credentials = s;
//mSmtpClient.Port = 587;
mSmtpClient.Send(mMailMessage);
// ********* //使用這些選項在源代碼中設置的郵件是越來越精發送// ****** }
由於提前
謝謝你解決了我的問題 – Sagar 2010-08-11 11:39:07