NpsSmtp is used to send email. Here is the sample codes for sending HTML formatted email with attachment.
|
var f = new NpsFile('test.txt'); f.OpenWriter(false); f.WriteString('hello from npsfile'); f.Close(); var client = new NpsSmtp("smtp.gmail.com",25); client.Connect("xjwebstar@gmail.com","mypassword"); client.SetCharset('UTF-8'); client.SetFrom('xjwebstar@gmail.com'); client.AddTo('jialin@jwebstar.com'); client.AddCc('support@jwebstar.com'); client.AddBcc('service@jwebstar.com'); client.SetSubject('test from npsemail'); client.SetHtmlMsg('<font color=red>hello from npsemail</font>'); client.AddAttach(f); client.Send(); |
| NpsSmtp |
NpsSmtp(String host,int port) Constructor. |
| void |
Connect(String user,String passwd) Connect to the smtp server for authentication using identified user and password. |
| void |
ConnectSSL(String user,String passwd) Connect to the smtp server using SSL for authentication. |
| void |
SetFrom(String from) Set the FROM field of the email to use the specified address. |
| void |
SetSubject(String subject) Set the email subject. |
| void |
AddTo(String to) Add a recipient TO to the email. |
| void |
AddBcc(String bcc) Add a blind BCC recipient to the email. |
| void |
SetCharset(String charset) Set the charset of the message.i,e,GBK、UTF-8、ISO8859-1.Default charset is ISO8859-1. |
| void |
SetTextMsg(String msg) Set the text content. |
| void |
SetHtmlMsg(String msg) Set the html content. |
| void |
AddAttach(NpsFile file) Attach a file located by file. |
| void |
Send() Sends the email. |