<script type=text/javascript> </script> <script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type=text/javascript> </script>
Jmail 參考說明Body : String
(v3.0)
信件體,正文,使用AppendText追加内容
如:JMail.Body = "Hello world"
Charset : String
(v3.0)
字元集,預設為"US-ASCII"
如:JMail.Charset = "US-ASCII"
ContentTransferEncoding : String
(v3.0)
指定内容傳送時的編碼方式,預設是"Quoted-Printable"
如:JMail.ContentTransferEncoding = "base64"
ContentType : String
(v3.0)
信件的contentype. 預設是"text/plain",但是可以設定為其他你想要的類型.
如果你以HTML格式發送郵件, 改為"text/html"即可。
如:JMail.ContentType = "text/html"
DeferredDelivery : Date
(v3.0)
設定延期發送. 如果郵件伺服器支援的話,消息到了這個時間才會發送
如:(Javascript)JMail.DeferredDelivery = new Date( 2000,
02,17 ).getVarDate();
Encoding : String
(v3.0)
這個屬性可以用來改變附件編碼方式(預設是"base64). 可以選擇使
用的是"base64", "uuencode" or "quoted-printable"
如:JMail.Encoding = "base64"
ErrorCode : Integer
(v3.0)
如果JMail.silent設定為true,ErrorCode包含的是錯誤代碼
如:Response.Write( JMail.ErrorCode );
ErrorMessage : String
(v3.0)
如果JMail.silent設定為true,包含的是錯誤資訊
如:Response.Write( JMail.ErrorMessage );
ErrorSource : String
(v3.0)
Contains the error source if JMail.silent is set to true
如:Response.Write( JMail.ErrorSource );
ISOEncodeHeaders : Boolean
(v3.0)
是否将信頭編碼成iso-8859-1字元集. 預設是true
如:JMail.ISOEncodeHeaders = false
Lazysend : Boolean
(v3.0)
這個屬性指定Jmail是否一直等到mail發送了然後傳回,或者緩沖這條消息然後
在背景發送。
然而設定了這個屬性,你就不能控制錯誤資訊。
注意:如果選擇了這個選項,屬性ServerAddress将無效,lazysend将通過dsn
查詢決定郵件伺服器,
在一些設定裡面,這可能有問題。
如:JMail.LazySend = true;
Log : String
(v3.0)
Jmail建立的日志,如果loging屬性設定為true
如:Response.Write( JMail.Log );
Logging : Boolean
(v3.0)
是否使用日志
如:JMail.Logging = true
MailDomain : String
(v3.0)
This can be used to override the EHLO/HELO statement to your mailserver
如:JMail.Maildomain = "hello.world.com"
MimeVersion : String
(v3.0)
指定mime版本。預設是"1.0"
如:JMail.MimeVersion = "1.0"
Priority : Integer
(v3.0)
優先級. 範圍在1-5之間
1 高優先級. 有些郵件程式稱之為緊急
2 也是高優先級
3 普通優先級
4 低優先級
5 最低的優先級
如:JMail.Priority = 3
Recipients : String
(v3.0)
隻讀屬性,傳回所有收件人
如:Response.Write( "" + JMail.Recipients + "" );
ReplyTo : String
(v3.0)
指定一個可選的回信位址
如:JMail.ReplyTo = "[email protected]"
ReturnReceipt : Boolean
(v3.0)
指定是否發件人需要一個回複收據. 預設是false
如:JMail.ReturnReceipt = true
Sender : String
(v3.0)
指定發件人的郵件位址
如:JMail.Sender = "[email protected]"
SenderName : String
(v3.0)
指定發件人的姓名
如:JMail.SenderName = "Bat man"
ServerAddress : String
(v3.0)
指定郵件伺服器的位址。可以指定多個伺服器,用分号點開。可以指定端口号。
如果serverAddress保持空白,JMail會嘗試解決遠端郵件伺服器,然後直接
發送到伺服器上去。
如:JMail.ServerAddress = "mail.mydom.net; mail2.mydom.net:2500"
Silent : Boolean
(v3.0)
如果設定為true,JMail不會抛出例外錯誤. JMail.execute() 會根據操作結
果傳回true或false
如:JMail.silent = true
SimpleLayout : Boolean
(v3.0)
設定為true,減少Jmail産生的header信頭
如:JMail.SimpleLayout = true
Subject : String
(v3.0)
設定消息的标題
如:JMail.Subject = "Dimac rocks big time!"
UsePipelining : Boolean
(v3.0)
Overrides if JMail should use pipelining on a server that supports it.
如:JMail.Pipelining = false
AddAttachment( FileName, [ContentType] )
(v3.0)
添加檔案附件到信件
如:JMail.AddAttachment( "c://autoexec.bat" );
AddCustomAttachment( FileName, Data )
(v3.0)
添加自定義附件. This can be used to attach "virtual files" like
a generated text string or certificate etc.
如:JMail.AddCustomAttachment( "readme.txt", "Contents of file" );
AddHeader( XHeader, Value )
(v3.0)
添加使用者定義的X-header到message
如:JMail.AddHeader( "Originating-IP","193.15.14.623" );
AddNativeHeader( Header, Value )
(v3.0)
添加信頭
如:JMail.AddNativeHeader( "MTA-Settings", "route" );
AddRecipient( Email )
(v3.0)
增加收件人
如:JMail.AddRecipient( "[email protected]" );
AddRecipientBCC( Email )
(v3.0)
增加密件收件人
如:JMail.AddRecipientBCC( "[email protected]" );
AddRecipientCC( Email )
(v3.0)
增加抄送收件人
如:JMail.AddRecipientCC( "[email protected]" );
AddRecipientEx( Email, Name )
(v3.0)
增加一個帶名字的收件人
如:JMail.AddRecipientEx( "[email protected]", "Dimac INFO" );
AddURLAttachment( bstrURL, bstrAttachAs, [bstrAuth] )
(v3.0)
下載下傳并添加一個來自url的附件. 第二個參數"AttachAs", 被用來指定信件
收到後的檔案名. 第3個可選參數是用來可選的WWW-鑒定.
如:JMail.AddURLAttachment
( "http://download.dimac.net/jmail/jmail.exe", "jmail.exe" )
AppendBodyFromFile( FileName )
(v3.0)
将一個檔案内容追加到正文後
如:JMail.AppendBodyFromFile( "c://mytext.txt" );
AppendText( Text )
(v3.0)
追加信件的正文内容
如:JMail.AppendText( "Text appended to message Body" );
ClearAttachments()
(v3.0)
清除附件清單
如:JMail.ClearAttachments();
ClearCustomHeaders()
(v3.0)
清除所有自定義的信頭
如:JMail.ClearCustomHeaders();
ClearRecipients()
(v3.0)
清除收件人清單
如:JMail.ClearRecipients();
Close()
(v3.0)
強制JMail關閉緩沖的與郵件伺服器的連接配接
如:JMail.Close();
Execute() : Boolean
(v3.0)
執行郵件的發送
如:JMail.Execute();
ExtractEmailAddressesFromURL( bstrURL, [bstrAuth] )
(v3.0)
從一個url下載下傳和添加email位址
如:JMail.ExtractEmailAddressesFromURL
( "http://duplo.org/generateEmailList.asp" );
GetMessageBodyFromURL( bstrURL, [bstrAuth] )
(v3.0)
清除message的正文,并用url的内容替換。Contenttype 會自動設定成UR
l的contentyp。第二參數(login and password)是可選的。
如:JMail.GetMessageBodyFromURL( "http://duplo.org/", "login:password" )
LogCustomMessage( Message )
(v3.0)
将使用者自定義消息加入JMail日志. 隻有屬性loging設定為true時,
這項功能才能起作用
如:JMail.LogCustomMessage( "Hello world" ); <script type=text/javascript> </script> <script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type=text/javascript> </script>
執行個體:
在.net項目裡,添加引用->COM 找到JMail 4.0 Library(按字母J可以快速找到)
先 using jmail;
- public static bool SendMail(string from, string to, string subject, string body)
- {
- try
- {
- Message jmail = new Message();
- jmail.Charset = "UTF-8";
- jmail.From = from;
- jmail.ContentType = "text/html";
- jmail.AddRecipient(to, null, null);
- jmail.MailServerUserName = "bogoso";
- jmail.MailServerPassWord = "xz352bgeb";
- jmail.Subject = subject;
- jmail.HTMLBody = body;
- jmail.Send("smtp.foxmail.com", false);
- }
- catch ()
- {
- return false;
- }
- return true;
- }