C ,乙個郵件傳送的類

2021-04-13 08:10:38 字數 2786 閱讀 5489

以下為郵件傳送使用**tp協議,在使用過程中曾經遇到郵件不能傳送的問題,如果你也遇到了,可以檢查一下windows的防火牆,windows自帶的防火牆如有啟用,可加入例外埠:25。如有安裝金山病毒防火牆,也需要將25埠的過濾禁用。

///郵件實體類:

using system;

using system.collections.generic;

using system.text;

using system.net.mail;

namespace qsystem.toolkit

public mail(string **tpserver, string username, string userpassword, string from, string to, string subject, string body)

: this(**tpserver, username, userpassword, from, to, subject, body, null)

public mail(string **tpserver, string username, string userpassword, string from, string to, string subject, string body, string attachments)

: this(**tpserver, username, userpassword, from, to, subject, body, attachments, false)

public mail(string **tpserver, string username, string userpassword, string from, string to, string subject, string body, string attachments, bool isbodyhtml)

: this(**tpserver, username, userpassword, from, to, subject, body, attachments, isbodyhtml, encoding.default)

public mail(string **tpserver, string username, string userpassword, string from, string to, string subject, string body, string attachments, bool isbodyhtml, encoding encoding)

string **tpserver;

///

/// **tp伺服器位址

///

public string **tpserver

set

}string username;

///

/// 使用者名稱

///

public string username

set

}string userpassword;

///

/// 密碼

///

public string userpassword

set

}string from;

///

/// 發件人

///

public string from

set

}string to;

///

/// 收件人

///

public string to

set

}string subject;

///

/// 主題

///

public string subject

set

}string body;

///

/// 內容

///

public string body

set

}bool isbodyhtml;

///

/// 是否以html格式傳送

///

public bool isbodyhtml

set

}encoding encoding;

///

/// 編碼格式

///

public encoding encoding

set

}string attachments;

///

/// 附件

///

public string attachments

set }}

}///傳送類

using system;

using system.collections.generic;

using system.text;

using system.net.mail;

using system.io;

namespace qsystem.toolkit

public void send(mail mails)

}public void send(mail mail)

}client.send(message);}}

}}}///呼叫示例

mail mail = new mail("**tp.***.com", "qiusz", "密碼", "qiusz@***.com",new string, "測試郵件標題", "測試郵件內容", null, true);

mailposter poster = new mailposter();

poster.send(mail); 

乙個通過web Mail傳送郵件的類

using system using system.web using system.web.mail using dottext.framework using dottext.framework.configuration namespace yournamespace.email region...

乙個通過web Mail傳送郵件的類

using system using system.web using system.web.mail using dottext.framework using dottext.framework.configuration namespace yournamespace.email region...

分享乙個非同步傳送郵件的類

首先要定義乙個郵件資訊的基類,如下所示 base message class used for emails public class message endregion region properties whom the message is to public virtual string t...