如何通过我的网站发送电子邮件 [英] how can send emails through my website

查看:158
本文介绍了如何通过我的网站发送电子邮件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好.我是创建邮件服务器的新手.所以我需要你的帮助.我创建一种形式.填写完所有详细信息后,我将邮件发送给客户.


我的代码是这样的:

 MailMessage邮件=  MailMessage();
        mail.To.Add(Txt_Email.Text);
        mail.From =  MailAddress("  span>);
        mail.Subject = " ;
        mail.Body = " ;
        SmtpClient smtp =  SmtpClient(" );
        // 待办事项:添加SMTP身份验证
        //  smtp.Credentials = new NetworkCredentials("user","password"); 
        smtp.Send(mail); 



但我提出了一个错误.请解决我的问题

解决方案

尝试此方法

 公共 静态 布尔值 SendingMail(字符串发​​件人,字符串收件人,字符串主题,字符串正文)
   {

           尝试
           {
               MailMessage m =  MailMessage(" ,收件人);
               m.Subject =主题;
               m.Body =身体;
               m.IsBodyHtml =  true ;
               m.From =  MailAddress(From);

               m.To.Add( MailAddress(To));
               SmtpClient smtp =  SmtpClient();
               smtp.Host = " ;

               NetworkCredential authinfo =  NetworkCredential("   pass @ 1234");
               smtp.UseDefaultCredentials =  false ;
               smtp.Credentials = authinfo;
               smtp.Send(m);
               返回 ;




           }
           捕获(例外)
           {
               返回 ;
           }
       }


希望这能给您一些想法
您必须在webconfig文件或同一页面中提供urs和密码的邮递区号.

 使用 System.Net.Mail;
添加 
smtp.Credentials =  System.Net.NetworkCredential
       (" "  YourGmailPassword");
 smtp.EnableSsl =  true ;
  smtp.Send(邮件);


如果问题仍然存在
添加
smpt.port =  587 ; 


在此处查看我的信息

如何通过asp.net发送电子邮件 [ ^ ]


hai everybody. i am new for creating mailserver. so i need a help from you. i create one form. after filling all the detaills, i nedd to send mail to the customer.


my code is like this:

MailMessage mail = new MailMessage();
        mail.To.Add(Txt_Email.Text);
        mail.From = new MailAddress("myemailid");
        mail.Subject = "Sending an email";
        mail.Body = "Date ";
        SmtpClient smtp = new SmtpClient("mail.gmail.com");
        //TODO: Add SMTP Authentication
        //smtp.Credentials = new NetworkCredentials("user", "password");
        smtp.Send(mail);



but i raise an error. plz any solve my problem

解决方案

try this method

public static Boolean SendingMail(string From, string To, string Subject, string Body)
   {

           try
           {
               MailMessage m = new MailMessage("<id@gmail.com>", To);
               m.Subject = Subject;
               m.Body = Body;
               m.IsBodyHtml = true;
               m.From = new MailAddress(From);

               m.To.Add(new MailAddress(To));
               SmtpClient smtp = new SmtpClient();
               smtp.Host = "mail.google.com";

               NetworkCredential authinfo = new               NetworkCredential("id@gmail.com", "pass@1234");
               smtp.UseDefaultCredentials = false;
               smtp.Credentials = authinfo;
               smtp.Send(m);
               return true;




           }
           catch (Exception ex)
           {
               return false;
           }
       }


hope this ll give some idea
u ve to give the mailid of urs and password either in webconfig file or in the same page.

using System.Net.Mail;
add this
smtp.Credentials = new System.Net.NetworkCredential
       ("YourUserName@gmail.com","YourGmailPassword");
 smtp.EnableSsl = true;
  smtp.Send(mail);


if problem still persist 
add 
smpt.port=587;


See my post here

How to send email through asp.net[^]


这篇关于如何通过我的网站发送电子邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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