在不提供SMTP IP地址的情况下在我的应用程序中实施电子邮件警报 [英] Implementing Email Alert in my application without giving SMTP IP address
本文介绍了在不提供SMTP IP地址的情况下在我的应用程序中实施电子邮件警报的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
朋友,
我需要在应用程序中实现电子邮件警报,而无需提供SMTP-IP地址.
使用IP,我可以按照以下步骤进行操作.
Hi Friends,
I need to implement Email Alerts in my application without giving SMTP-IP Address.
With IP I have done that as following.
private void SendingMail(string toList, string subject, string sentby)
{
//Sending Mail....
MailMessage message = new MailMessage();
SmtpClient smtpClient = new SmtpClient();
string msg = string.Empty;
string body = "You have received a file from Honey";
MailServerIp = "172.185.30.9"; // Changed IP not orginal
MailFrom = "Honey@gmail.com";// Just sample mail not orginal
MailFromPwd = "asdfasdf" ; // just sample pwd not original
try
{
MailAddress fromAddress = new MailAddress(MailFrom);
message.From = fromAddress;
message.To.Add(toList);
message.Subject = "Mail Alert Sent Successfylly";
message.IsBodyHtml = true;
if (body != "")
message.Body = body;
smtpClient.Host = MailServerIp;
smtpClient.Credentials = new NetworkCredential(fromAddress.ToString(), MailFromPwd);
smtpClient.Send(message); //send.....
message.To.Clear();
}
catch (Exception ex)
{
msg = ex.Message;
}
}
我不需要提供IP地址.
I want that without giving IP address.
推荐答案
您可以引用此
这篇关于在不提供SMTP IP地址的情况下在我的应用程序中实施电子邮件警报的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文