namespace sendemail
public thread thread = null;
public autotimeinfo autotimeinfo;
public bool exitthread=false;
public struct autotimeinfo
int week = 0;
int hour = 0;
int minit = 0;
exitthread = false;
bool enablesend = false;
bool checktime=true;
while(true)
else if(compare=="1")
hour = dt.hour;
minit = dt.minute;
if(checktime)
}if (autotimeinfo.weekend != week || autotimeinfo.hour != hour ||autotimeinfo.minite != minit)
if(enablesend)
));}
if(exitthread)
thread.sleep(2);
}//************************************
system.net.mail.mailmessage msg = new system.net.mail.mailmessage();
msg.to.add(emailinfo.receive);
msg.cc.add(emailinfo.copy);
msg.from = new mailaddress(emailinfo.sendip, emailinfo.senddisplayname, system.text.encoding.utf8);
msg.subject = emailinfo.subject;//郵件標題
msg.subjectencoding = system.text.encoding.utf8;//郵件標題編碼
msg.body = emailinfo.body;//郵件內容
msg.bodyencoding = system.text.encoding.utf8;//郵件內容編碼
msg.isbodyhtml = true;//是否是html郵件
msg.priority = mailpriority.normal;//郵件優先順序
string sfile = emailinfo.otherfilepath;//新增附件
if(sfile!="")
smtpclient client = new smtpclient();
client.credentials = new system.net.networkcredential(emailinfo.sendip, emailinfo.sendpassword);
//註冊的郵箱和密碼
client.host = "smtp.163.com";//根據郵箱型別固定
object userstate = msg;
trycatch (system.net.mail.smtpexception ex)
}private void button1_click(object sender, eventargs e)//設定
else
private void button_send_click(object sender, eventargs e)
private void button_selectpath_click(object sender, eventargs e)//郵箱設定
else}}
else if(autoset.radiobutton_monthset.checked)
else
}catch(exception ee)
private void checkbox_autosend_checkedchanged(object sender, eventargs e)
else}}
}}public class emailinfo
//接收者
public string copy //抄送者
public string sendip //傳送方
public string sendpassword //密碼
public string senddisplayname //傳送者顯示
public string subject //郵件主題
public string body //郵件內容
public string otherfilepath //附件
//呼叫
/*email email = new email();
email.mailfrom = "";//傳送人的郵箱位址
email.mailpwd = "";//傳送人郵箱的密碼
email.mailsubject = "";//郵件主題
email.mailbody = "";//郵件內容
email.isbodyhtml = true; //是否是html
email.host = "smtp.163.com";//如果是qq郵箱則:smtp:qq.com,依次類推
email.mailtoarray = new string ;//接收者郵件集合
= new string ;//抄送者郵件集合
email.send().tostring();
* */}}
郵件傳送例項
sendemail public result sendemail string id,string toemail,string ccemail 模板郵件傳送 param mailbean 郵件類 param toemails 收件人 param ccemails 抄送人 public resul...
C 呼叫 Outlook傳送郵件例項
新增引用 microsoft.office.interop.outlook using system using system.collections.generic using system.linq using system.text using system.net.mail using sy...
ORACLE傳送郵件 例項
create or replace procedure send mail p recipient varchar2,郵件接收人 p subject varchar2,郵件標題 p message varchar2 郵件正文 is 下面四個變數請根據實際郵件伺服器進行賦值 v mailhost va...