Table of Contents

Class Mailer

Namespace
ZapLib
Assembly
ZapLib.dll

SMTP 郵件發送工具

public class Mailer
Inheritance
Mailer
Inherited Members

Constructors

Mailer(string, string, string, int, bool, int)

建構子,初始化必要 SMTP 物件

public Mailer(string MAIL_HOST, string MAIL_ACT, string MAIL_PWD, int MAIL_PORT = 587, bool MAIL_SSL = true, int MAIL_RETRY = 1)

Parameters

MAIL_HOST string

SMTP Server 位置

MAIL_ACT string

登入帳號

MAIL_PWD string

登入密碼

MAIL_PORT int

SMTP Server 埠號

MAIL_SSL bool

是否啟用 SSL

MAIL_RETRY int

是否啟用失敗重寄機制,預設為啟用

Properties

AttachmentsList

郵件的附件列表

public List<MimePart> AttachmentsList { get; }

Property Value

List<MimePart>

ErrMsg

錯誤訊息

public string ErrMsg { get; }

Property Value

string

SecureSocketOption

使用連線的加密協議

public SecureSocketOptions SecureSocketOption { get; set; }

Property Value

SecureSocketOptions

mail

EMAIL 物件

public MimeMessage mail { get; set; }

Property Value

MimeMessage

smtp

SMTP 連線物件

public SmtpClient smtp { get; set; }

Property Value

SmtpClient

Methods

AddAttachments(string)

新增郵件附加檔案,回傳檔案的 content id

public string AddAttachments(string path)

Parameters

path string

檔案實體路徑,如果檔案不存在則回傳 null

Returns

string

檔案的 content id

Send(string, string, string, string, string, string[])

送出郵件

public bool Send(string to, string subject, string body, string cc = null, string bcc = null, string[] attchments = null)

Parameters

to string

發送到指定 email 位置,多個用逗號隔開

subject string

信件主旨

body string

信件內文

cc string

副本 (不需要可傳 NULL)

bcc string

密件副本 (不需要可傳 NULL)

attchments string[]

附加檔案

Returns

bool