如何使用c#以windows形式发送电子邮件 [英] how to send emails in windows form using c#

查看:61
本文介绍了如何使用c#以windows形式发送电子邮件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我如何向任何用户发送邮件

喜欢

gmail,hotmail,siffy,yahoo,rediff和其他服务器。



c#.net窗口应用程序

how i can send mails to any user
like
gmail,hotmail,siffy,yahoo,rediff and other servers.

in c#.net window application

推荐答案

目标电子邮件服务器无关紧要。



通过这些链接... http://www.codeproject.com/ search.aspx?q = c%23 +发送+电子邮件 [ ^ ]



Google还有更多
The target email server is irrelevant.

Work through these links ... http://www.codeproject.com/search.aspx?q=c%23+send+email[^]

Google has many more


\\你可以尝试下面的代码





使用System.Net.Mail;

使用System.Net;



string From =abc@gmail.com; \\ yourour email id

string Password =abc; \\ \\\您的密码

string To =def@xyz.com; \\ email将在哪个邮件上发送邮件

MailMessage msg = new MailMessage();

SmtpClient client = new SmtpClient();

client.Port = 587; \\如果您的电子邮件ID来自gmail那么请写端口号,那么您的端口将是587
client.Host =smtp.gmail.com; \\write您的电子邮件ID的smtp名称

client.EnableSsl = true; \\写你的Id的ssl

client.Timeout = 50000000;

client.Credentials = new NetworkCredential(From,Password);

msg.From = new MailAddress(From,);

msg.Subject =Test Mail; \\ write您的电子邮件主题

msg.Body =12626; \\内容您要邮寄

client.Send(msg);

MessageBox.show(邮件成功发送!!!);





\\ smtp名称和端口没有可以很容易在谷歌搜索

喜欢例如,如果您的电子邮件ID是从gmail配置的,那么gmail使用smtp名称作为smtp.gmail.com,其输出端口号为587/25

和SSl必须保持正确
\\you can try the following code


using System.Net.Mail;
using System.Net;

string From = "abc@gmail.com";\\your email id
string Password = "abc";\\ your password
string To = "def@xyz.com";\\email id on which mail is to be sent
MailMessage msg = new MailMessage();
SmtpClient client = new SmtpClient();
client.Port = 587;\\ write the port no for example if your email id is from gmail then your port will be 587
client.Host = "smtp.gmail.com";\\write smtp name of your email id
client.EnableSsl = true;\\ write ssl of your Id
client.Timeout = 50000000;
client.Credentials = new NetworkCredential(From, Password);
msg.From = new MailAddress(From,"");
msg.Subject = "Test Mail";\\ write Subject Of Your Email
msg.Body = "12626";\\ contents you want to mail
client.Send(msg);
MessageBox.show("Mail Successfully Sent !!!");


\\ smtp name and port no can easily be searched on google
like for example if your email id is configured from gmail

then gmail uses smtp name as "smtp.gmail.com" its outgoing port no "587"/"25"
and SSl has to kept true


这篇关于如何使用c#以windows形式发送电子邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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