C 傳送郵件及附件

2021-07-05 18:57:21 字數 1055 閱讀 5394

protected void button1_click(object sender, eventargs e)

///

/// c#傳送郵件函式

///

/// 傳送者郵箱

/// 傳送人

/// 接受者郵箱

/// 收件人

/// 主題

/// 內容

/// 附件

/// smtp伺服器

/// 郵箱

/// 密碼

///

public bool sendmail(string sfrom, string sfromer, string sto, string stoer, string ssubject, string sbody, string sfile, string ssmtphost, string ssmtpuser, string ssmtppass)

郵件標題

omail.subject = ssubject;

郵件內容

omail.body = sbody;

郵件格式

omail.isbodyhtml = false;

郵件採用的編碼

omail.bodyencoding = system.text.encoding.getencoding("gb2312");

設定郵件的優先順序為高

omail.priority = mailpriority.high;

傳送郵件

smtpclient client = new smtpclient();

client.usedefaultcredentials = false; 

client.host = ssmtphost;

client.credentials = new networkcredential(ssmtpuser, ssmtppass);

client.deliverymethod = smtpdeliverymethod.network;

trycatch (exception err)

finally

}

python傳送郵件及附件

import smtplib import datetime from email.header import header from email.mime.text import mimetext from email.mime.image import mimeimage from email....

c 傳送郵件 附件

winform窗體 如下 using system using system.collections.generic using system.componentmodel using system.data using system.drawing using system.linq using ...

傳送附件郵件demo

import smtplib from email.mime.text import mimetext from email.mime.multipart import mimemultipart from email.mime.image import mimeimage from email.h...