<del id="d4fwx"><form id="d4fwx"></form></del>
      <del id="d4fwx"><form id="d4fwx"></form></del><del id="d4fwx"><form id="d4fwx"></form></del>

            <code id="d4fwx"><abbr id="d4fwx"></abbr></code>
          • 如何編寫smtp發(fā)送帶附件的郵件代碼-創(chuàng)新互聯(lián)

            這篇文章主要講解了“如何編寫smtp發(fā)送帶附件的郵件代碼”,文中的講解內(nèi)容簡單清晰,易于學習與理解,下面請大家跟著小編的思路慢慢深入,一起來研究和學習“如何編寫smtp發(fā)送帶附件的郵件代碼”吧!

            成都創(chuàng)新互聯(lián)從2013年成立,是專業(yè)互聯(lián)網(wǎng)技術(shù)服務(wù)公司,擁有項目網(wǎng)站設(shè)計制作、成都網(wǎng)站設(shè)計網(wǎng)站策劃,項目實施與項目整合能力。我們以讓每一個夢想脫穎而出為使命,1280元阜新做網(wǎng)站,已為上家服務(wù),為阜新各地企業(yè)和個人服務(wù),聯(lián)系電話:13518219792

            復(fù)制代碼 代碼如下: 

                MailMessage mmsg = new MailMessage();
                mmsg.Subject = "郵件標題";
                mmsg.Body = "郵件內(nèi)容";
                mmsg.To.Add("[email protected]");//接收郵箱
                byte[] bytes = System.Text.Encoding.Default.GetBytes
                    (@"<table><tr><td width=150>1234567891234567
                    </td><td width=80>12345678</td></tr></table>");
                MemoryStream ms = new MemoryStream(bytes);
                ContentType ct = new ContentType();
                //附件文件類型
                ct.MediaType = MediaTypeNames.Text.Html;
                //附件名稱,可以是其它后綴名
                ct.Name = "附件名稱" + DateTime.Now.ToString() + ".html";
                mmsg.Attachments.Add(new Attachment(ms, ct));
                //SMTP簡單郵件協(xié)議
                System.Net.Mail.SmtpClient sc
                    = new System.Net.Mail.SmtpClient();
                sc.Host = "127.0.0.1";//主機地址
                sc.Port = 25;//端口
                //發(fā)送郵箱賬號和密碼
                sc.Credentials =
                    new System.Net.NetworkCredential("account", "password");
                //發(fā)送郵箱
                mmsg.From = new MailAddress("[email protected]");
                sc.Send(mmsg);
                //釋放流資源
                ms.Close();
                ms.Dispose();


            另附上一個.net使用smtp發(fā)送帶附件郵件的實例

            復(fù)制代碼 代碼如下:

            public static void sendEmail(string toAddress, string emailbody)
            {
            var fromAddress = ConfigurationManager.AppSettings["EmailAddress"];
            string fromPassword = ConfigurationManager.AppSettings["EmailPassword"].ToString();
            const string subject = "Job Recommendation";
            var smtp = new SmtpClient
            {
            Host = ConfigurationManager.AppSettings["SmtpServer"].ToString(),
            Port = int.Parse(ConfigurationManager.AppSettings["SmtpPort"]),
            EnableSsl = true,
            DeliveryMethod = SmtpDeliveryMethod.Network,
            UseDefaultCredentials = false,
            Credentials = new NetworkCredential(fromAddress, fromPassword)
            };
            using (var message = new MailMessage(fromAddress, toAddress, subject, HttpUtility.HtmlEncode(emailbody)))
            {
            smtp.Send(message);
            }
            }
            <add key="EmailAddress" value="**********@gmail.com"/>//Email Address
            <add key="EmailPassword" value="*********"/> //Emial PWD
            <add key="SmtpServer" value="smtp.gmail.com"/>
            <add key="SmtpPort" value="587"/>
            <--帶附件版本->
            var fromAddress = "[email protected]";
            string fromPassword = "yj1989120";
            const string subject = "CV";
            var smtp = new SmtpClient
            {
            Host = "smtp.gmail.com",
            Port = 587,
            EnableSsl = true,
            DeliveryMethod = SmtpDeliveryMethod.Network,
            UseDefaultCredentials = false,
            Credentials = new NetworkCredential(fromAddress, fromPassword)
            };
            MailMessage email=new MailMessage(fromAddress, "[email protected]");
            email.Subject = "INLINE attachment TEST";
            email.IsBodyHtml = true;
            string attachmentPath = "C:\\3.jpeg";
            Attachment inline = new Attachment(attachmentPath);
            inline.ContentDisposition.Inline = true;
            inline.ContentDisposition.DispositionType = DispositionTypeNames.Inline;
            //inline.ContentId = "1";
            //inline.ContentType.MediaType = "image/png";
            inline.ContentType.Name = Path.GetFileName(attachmentPath);
            email.Attachments.Add(inline);
            email.Body = "test";
            smtp.Send(email);
            email.Dispose();
            //如果沒有路徑,用Stream
            Attachment letter = new Attachment(FileUploadLetter.FileContent, FileUploadLetter.PostedFile.ContentType);
            letter.ContentDisposition.Inline = true;
            letter.ContentDisposition.DispositionType = DispositionTypeNames.Inline;
            //inline.ContentId = "1";
            letter.ContentType.MediaType = FileUploadLetter.PostedFile.ContentType;
            letter.ContentType.Name = Path.GetFileName(FileUploadLetter.PostedFile.FileName);
            letter.Name = Path.GetFileName(FileUploadLetter.PostedFile.FileName);


            感謝各位的閱讀,以上就是“如何編寫smtp發(fā)送帶附件的郵件代碼”的內(nèi)容了,經(jīng)過本文的學習后,相信大家對如何編寫smtp發(fā)送帶附件的郵件代碼這一問題有了更深刻的體會,具體使用情況還需要大家實踐驗證。這里是創(chuàng)新互聯(lián)網(wǎng)站建設(shè)公司,,小編將為大家推送更多相關(guān)知識點的文章,歡迎關(guān)注!

            分享題目:如何編寫smtp發(fā)送帶附件的郵件代碼-創(chuàng)新互聯(lián)
            當前地址:http://www.jbt999.com/article20/cdejco.html

            成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供網(wǎng)站排名、外貿(mào)建站、用戶體驗、網(wǎng)站內(nèi)鏈網(wǎng)站導(dǎo)航、Google

            廣告

            聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:[email protected]。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)

            商城網(wǎng)站建設(shè)

              <del id="d4fwx"><form id="d4fwx"></form></del>
              <del id="d4fwx"><form id="d4fwx"></form></del><del id="d4fwx"><form id="d4fwx"></form></del>

                    <code id="d4fwx"><abbr id="d4fwx"></abbr></code>
                  • 日本黄免费| 人人爽人人奭人人片AV | 黄色片免费一级 片 | 国产淫淫淫 | 996热在线观看 |