我的电子邮件申请代码中的更正 [英] Correction in my code for email application

查看:76
本文介绍了我的电子邮件申请代码中的更正的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


这是pankaj
这是我用于运行电子邮件应用程序的代码.但是它无法正常工作,这是什么问题.请检查我的代码,然后对我进行同样的答复,谢谢.

Hi,
This is pankaj here
Here is my code for running email application.But its not working what is the problem in it.Please check my code and respond me for the same,Thanks in advance

System.Net.Mail.MailMessage message = new System.Net.Mail.MailMessage();
 message.From = new MailAddress("education@jssindia.com");
            message.To.Add("singh7pankaj@gmail.com");
 message.Subject = "Welcome Surabhi Publishing House User!";
 message.Body = "hello";

            message.IsBodyHtml = true;
            message.DeliveryNotificationOptions = System.Net.Mail.DeliveryNotificationOptions.OnFailure;
SmtpClient client = new SmtpClient();
            client.UseDefaultCredentials = true;
            client.Timeout = 100000;
 client.Send(message);


在Web配置文件中,我附加的内容在这里


In web config file what i attach is here

<system.net>>
<mailsettings>
<smtp from="education@jssindia.com">
<network defaultcredentials="true" host="myhostname" password="mypassword" username="myusername" port="25">;
</network></smtp>
</mailsettings>
</system.net>

推荐答案

好像您正在使用GMAIL接收电子邮件.

用途:
主持人:smtp.gmail.com
端口:587

确保配置条目值正确. (目前,它看起来像是复制粘贴)

此处有更多详细信息:
使用带有附件的Gmail帐户发送电子邮件 [ ^ ]
通过SMTP发送具有Gmail,Yahoo,AOL和实时邮件的电子邮件 [使用ASP.NET发送来自网站的电子邮件 [在ASP.NET中发送电子邮件的教程 [
Looks like you are using GMAIL for email.

Use:
host: smtp.gmail.com
port: 587

Make sure the config entry values are correct. (for now, it looks a copy-paste)

More details here:
Send Emails with Gmail Account with Attachment[^]
Sending Email with Gmail, Yahoo, AOL, and Live Mail Via SMTP[^]

UPDATE:
Use ASP.NET to send Email from Website[^]
Tutorials on sending Email in ASP.NET[^]


MailMessage message = new MailMessage();
SmtpClient smtp =新的SmtpClient();
message.From = new MailAddress("mail @ examples");
message.To.Add(new MailAddress("asifkem@gmail.com"));
字符串msg ="Hi";

message.IsBodyHtml = true;
message.Subject =新任命| Apple Medical Center";
message.Body = msg;
smtp.Host ="relay-hosting.secureserver.net";
smtp.Port = 25;
smtp.UseDefaultCredentials = false;
smtp.Send(message);
状态=真;

//导入此名称空间
使用System.Net.Mail;
MailMessage message = new MailMessage();
SmtpClient smtp = new SmtpClient();
message.From = new MailAddress("mail@examples");
message.To.Add(new MailAddress("asifkem@gmail.com"));
string msg = "Hi";

message.IsBodyHtml = true;
message.Subject = "New Appointment | Apple Medical Center";
message.Body = msg;
smtp.Host = "relay-hosting.secureserver.net";
smtp.Port = 25;
smtp.UseDefaultCredentials = false;
smtp.Send(message);
status = true;

//Import this namespace
using System.Net.Mail;


string strTo = email;
string strFrom = "mail@applemedicalcenter";
string strSubject = "New Appointment";
string msg = "Hi, Admin\n" + "\n"
+ " " + "Mr/Mrs: " + name + " had sent a request for a new appointment.His details are mentioned below:\n"

SmtpMail.SmtpServer = "localhost";
SmtpMail.Send(strFrom, strTo, strSubject, msg);
status = true;


这篇关于我的电子邮件申请代码中的更正的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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