在C#winforms中向任何服务提供商(GMAIL,YAHOO,HOT MAIL或任何商业邮件)发送邮件 [英] sending a mail with any Service providers(GMAIL,YAHOO, HOT MAIL or any Business mail) in C# winforms

查看:49
本文介绍了在C#winforms中向任何服务提供商(GMAIL,YAHOO,HOT MAIL或任何商业邮件)发送邮件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

朋友们,





如何向任何类型的服务提供商发送邮件。我不想仅用Gmail来限制客户。





请帮助我......

解决方案

Microsoft .NET框架提供了两个名称空间System.Net和System.Net.Sockets,用于通过Internet发送或接收数据。 SMTP协议用于从C#发送电子邮件。 C#使用System.Net.Mail命名空间来发送电子邮件。要发送电子邮件,您需要配置SMTP服务器。如果您没有任何SMTP,则可以使用免费的SMTP服务器。您还可以使用您的Gmail帐户。



更多详细信息,例如: http://cybarlab.blogspot.com/2013/03/send-e-mail-using-c-sharp.html



希望它会对你有所帮助。



坦克&最好的考虑


只需使用配置文件: http://hazaa.com.au/blog/how-to-store-smtp-mail-settings-in-the-appconfig-or-webconfig-file/ [ ^ ],或提供您自己的配置机制并按代码设置必要的SmtpClient属性。

本主题中有用的文章:在.NET Framework中发送邮件 [ ^ ]




使用这个可能对你有所帮助。





protected void SendEMail(字符串MailTo,字符串MailFrom,字符串MailSubject,字符串MailBody, string CC,string BCC,string Host,string Password,int PortNo)

{

MailMessage objEmail = new MailMessage();



objEmail.From = new MailAddress(MailFrom);



string [] MailItem = MailTo.Split('';'');

for(int i = 0;我< MailItem.Length; i ++)

{

objEmail.To.Add(new MailAddress(MailItem [i]));

}



objEmail.Subject = MailSubject;

objEmail.Body = MailBody;

objEmail.IsBodyHtml = true;

objEmail.Sender = new MailAddress(MailFrom);

objEmail.Priority = MailPriority.High;



try

{

SmtpClient客户端=新的SmtpClient();

client.Host =主机;

ICredentialsByHost crd = new NetworkCredential(MailFrom,密码);

client.Credentials = crd;

client.EnableSsl = true;

client.Port = PortNo;

client.Send(objEmail);

}

catch(Exception exc)

{

}

}



通话模式:



SendEMail(ToEMAIL,FromMAIL,主题行,邮件内容,CC ID,BCC ID,smtp.gmail.com,密码,587);

Hi friends,


How can able to send a mail with any kind of service providers. I don''t want to restrict the Customer with only Gmail.


Kindly help me......

解决方案

The Microsoft .NET framework provides two namespaces, System.Net and System.Net.Sockets to send or receive data over the Internet. SMTP protocol is using for sending email from C#. C# use System.Net.Mail namespace for sending email.To send e-mail you need to configure SMTP server. If you don’t have any SMTP, you can use free SMTP server. You can also use your gmail account.

More details with example: http://cybarlab.blogspot.com/2013/03/send-e-mail-using-c-sharp.html

Hope it will help you.

Tanks & best regard


Simply use config file: http://hazaa.com.au/blog/how-to-store-smtp-mail-settings-in-the-appconfig-or-webconfig-file/[^], or provide your own configuration mechanism and set the necessary SmtpClient properties by code.
A useful article in this topic: Sending Mails in .NET Framework[^]


Hi,
use this one might be helps you.


protected void SendEMail(string MailTo, string MailFrom, string MailSubject, string MailBody,string CC, string BCC,string Host,string Password,int PortNo)
{
MailMessage objEmail = new MailMessage();

objEmail.From = new MailAddress(MailFrom);

string[] MailItem = MailTo.Split('';'');
for (int i = 0; i < MailItem.Length; i++)
{
objEmail.To.Add(new MailAddress(MailItem[i]));
}

objEmail.Subject = MailSubject;
objEmail.Body = MailBody;
objEmail.IsBodyHtml = true;
objEmail.Sender = new MailAddress(MailFrom);
objEmail.Priority = MailPriority.High;

try
{
SmtpClient client = new SmtpClient();
client.Host = Host;
ICredentialsByHost crd = new NetworkCredential(MailFrom, Password);
client.Credentials = crd;
client.EnableSsl = true;
client.Port = PortNo;
client.Send(objEmail);
}
catch (Exception exc)
{
}
}

Calling Pattern :

SendEMail("ToEMAIL", "FromMAIL", "Subject Line", "Mail Content", "CC ID", "BCC ID","smtp.gmail.com", "Password",587);


这篇关于在C#winforms中向任何服务提供商(GMAIL,YAHOO,HOT MAIL或任何商业邮件)发送邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆