嗨,我正在使用C#在asp.net中发送包含用户名和密码的邮件 [英] Hi i m sending mail which contains username and password in asp.net using c#

查看:68
本文介绍了嗨,我正在使用C#在asp.net中发送包含用户名和密码的邮件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,我使用c#.. asp发送包含用户名和密码以及asp.net中的一些文本的邮件,它工作正常,但是我的问题是我必须更改该邮件中用户名和密码的颜色和字体大小. ..plss提前帮助我表示紧急的感谢
在我的代码中


hi i m sending mail which contains username and password along with that some text in asp.net using c#..its working perfectly but my problem is that i have to change the colour and font size of username and password in that mail...plss help me out its urgent thanks in advance
here in my code for that


public void sendmail()
   {
       // Gmail Address from where you send the mail
       var fromAddress = syui08@gmail.com";
       // any address where the email will be sending
       var toAddress = Email.Text.ToString();
       //Password of your gmail address
       const string fromPassword = gdfgfg;
       // Passing the values and make a email formate to display
       string subject = "Phd / Msc Engg Candidate Status";
      
       string usrname = LoginID.Text.ToString();
       TextBox1.Text = usrname.ToString();
       string usrname1 = TextBox1.Text.ToString();

     
       string pass = pas1;
       TextBox2.Text = pass.ToString();
       string pass1 = TextBox2.Text.ToString();

       string body = "Dear Sir/Madam,\n\n";
       body += " Kindly Requesting To Check your PhD.D/Msc Engg Candidate status, Please find the following steps\n";
       body += "1)  --   \n";
       body += "--Please paste this URL in the Browser and enter the following Username and password\n";
       body += "\n";
       body += "2) User Name:: " + usrname1 + "\n";
       body += "\n";
       body += "      Password:: " + pass1 + "\n";
       body += "\n";
       body+="3) Select the candidate in the search candidates and check the Status \n";
       body += "\n";
       body += "4) Please leave your feedback or Queries at phdvtu08@gmail.com\n";
       body += " Kind attention::-- Please use the Latest Version Browser (Ex- Mozilla, Firefox, IE 7.0) for the better output \n";
       body += "\n";
       body += "\n";
       body += "Thanks & Regards \n";
       body += " PhD Admin\n";
       //body += "Question: \n" + Comments.Text + "\n";
       // smtp settings
       var smtp = new System.Net.Mail.SmtpClient();
       {
           smtp.Host = "smtp.gmail.com";
           smtp.Port = 587;
           smtp.EnableSsl = true;
           smtp.DeliveryMethod = System.Net.Mail.SmtpDeliveryMethod.Network;
           smtp.UseDefaultCredentials = true;
           smtp.Credentials = new NetworkCredential(fromAddress, fromPassword);
           smtp.Timeout = 20000;
           //smtp.EnableSsl = true;
       }
       // Passing values to smtp object

       smtp.Send(fromAddress, toAddress, subject, body);
   }


在这里,我想更改用户名和密码的颜色和字体,请事先帮助我.


here i want to change the colour and font of User Name and password plss help me out thanks in advance

推荐答案

最简单的方法是将电子邮件设置为使用HTML.然后,您可以使用常规" html命令以所需的任何方式设置格式.如果您在这里查看:使用C#发送电子邮件带有或不带有附件:通用例程. [ ^ ],您会发现默认情况下使用HTML的通用例程-否则,您必须手动设置MailMessage.

顺便说一句:您确实意识到IE7.0已经过时了几年吗?它在3年前被取代,现在可以使用IE10!
The easiest way is to set the email to use HTML. You can then use "normal" html commands to format things any way you need. If you have a look here: Sending an Email in C# with or without attachments: generic routine.[^] you will find a generic routine which uses HTML by default - otherwise you would have to set up a MailMessage manually.

BTW: You do realize that IE7.0 is several years out of date? It was superseded 3 years ago, and IE10 is available now!
Please use the Latest Version Browser (Ex- Mozilla, Firefox, IE 7.0) for the better output


这篇关于嗨,我正在使用C#在asp.net中发送包含用户名和密码的邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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