import com;


namespace com; 
import util.metaProperty;
 
class smtp{
	ctor( /*输入构造函数所需要的参数*/ ){
		this.objEmail = ..com.CreateObject("CDO.Message");
		this.objEmail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport").Value = 25;
		this.objEmail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusing").Value  = 2
		this.objEmail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate").Value  = 1;//cdoAuthentication.cdoBasic
	};
	@metaProperty;
}

namespace smtp{ 
    metaProperty = ..util.metaProperty(

		from = {
			_get = function(){  
				return owner[["objEmail"]].From;
			}
			_set = function( value ){  
		  
				owner[["objEmail"]].From =  value; 
			} 	
		};
		to = {
			_get = function(){  
				return owner[["objEmail"]].To;
			}
			_set = function( value ){
				owner[["objEmail"]].To =  value; 
			} 	
		};
		cc = {
			_get = function(){  
				return owner[["objEmail"]].Cc;
			}
			_set = function( value ){
				owner[["objEmail"]].Cc =  value; 
			} 	
		};
		bcc = {
			_get = function(){  
				return owner[["objEmail"]].Bcc;
			}
			_set = function( value ){
				owner[["objEmail"]].Bcc =  value; 
			} 	
		};
		subject = {
			_get = function(){  
				return owner[["objEmail"]].Subject;
			}
			_set = function( value ){
				owner[["objEmail"]].Subject =  value; 
			} 	
		};
		text = {
			_get = function(){  
				return owner[["objEmail"]].Textbody;
			}
			_set = function( value ){
				owner[["objEmail"]].Textbody =  value; 
			} 	
		};
		html = {
			_get = function(){  
				return owner[["objEmail"]].HTMLBody;
			}
			_set = function( value ){
				owner[["objEmail"]].HTMLBody =  value; 
			} 	
		};
		addfile = function(...){
			var t = {...}
			for(i,attachfile in t){
				owner[["objEmail"]].AddAttachment( attachfile )
			}
		
		}
		gethtml = function(url){
			if(url[1]=="/" || url[1]=="\")
				url = ..io.fullpath(url)
				
			if(url[2]==':'#)
				url = "file://"+url;
				
			return owner[["objEmail"]].CreateMHTMLBody( url,31 ) 
		}
		username = {
			_get = function(){  
				return owner[["objEmail"]].Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusername").Value ;
			}
			_set = function( value ){
				owner[["objEmail"]].Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusername").Value  =  value; 
			} 	
		};
		password = {
			_get = function(){  
				return owner[["objEmail"]].Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendpassword").Value;
			}
			_set = function( value ){
				owner[["objEmail"]].Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendpassword").Value  =  value; 
			} 
		}
		ssl = { 
			//use SSL for the connection (false or true) 
			_get = function(){  
				return owner[["objEmail"]].Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpusessl").Value ;
			}
			_set = function( value ){
				owner[["objEmail"]].Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpusessl").Value   =  value; 
			}  
		}
		server = {  
			_get = function(){  
				return owner[["objEmail"]].Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver").Value  ;
			}
			_set = function( value ){
				owner[["objEmail"]].Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver").Value    =  value; 
			} 
		}
		port = {  
			_get = function(){  
				return owner[["objEmail"]].Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport").Value ;
			}
			_set = function( value ){
				assert(type(value)==type.number,"端口必须是一个整数值")
				owner[["objEmail"]].Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport").Value   =  value; 
			} 
		}
		authenticate = {  
			_get = function(){  
				return owner[["objEmail"]].Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate").Value ;
			}
			_set = function( value ){ 
				owner[["objEmail"]].Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate").Value  =  value; 
			}
		}
		timeout = {  
			//Connection Timeout in seconds (the maximum time CDO will try to establish a
			_get = function(){  
				return owner[["objEmail"]].Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout").Value ;
			}
			_set = function( value ){ 
				owner[["objEmail"]].Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout").Value  =  value; 
			} 
		}
		sendusing = {   
			_get = function(){  
				return owner[["objEmail"]].Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusing").Value ;
			}
			_set = function( value ){ 
				owner[["objEmail"]].Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusing").Value =  value; 
			}
		}  
		reply = {   
			_get = function(){  
				return owner[["objEmail"]].Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpuserreplyemailaddress").Value ;
			}
			_set = function( value ){ 
				owner[["objEmail"]].Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpuserreplyemailaddress").Value =  value; 
			}
		}      
		send = function(){
			owner[["objEmail"]].Configuration.Fields.Update() 
    		owner[["objEmail"]].Send()
		} 

	) 
	
	//常量定义开始 CDO.Message;
	
	cdoSendUsing={
	/*intellisense(com.smtp.cdoSendUsing)*/ 
	cdoSendUsingPickup=1;
	cdoSendUsingPort=2 
	/*end intellisense*/
	};
	
	cdoAuthentication={
	/*intellisense(com.smtp.cdoAuthentication)*/ 
	cdoBasic=1;
	cdoAnonymous=0;
	cdoNTLM=2 
	/*end intellisense*/
	};
	
	cdoReferenceType={
	/*intellisense(com.smtp.cdoReferenceType)*/ 
	cdoRefTypeLocation=1;
	cdoRefTypeId=0 
	/*end intellisense*/
	};
	
	cdoTimeZoneId={
	/*intellisense(com.smtp.cdoTimeZoneId)*/ 
	cdoWestCentralAfrica=69;
	cdoGreenland=60;
	cdoTehran=25;
	cdoIndiana=34;
	cdoFiji=40;
	cdoFloating=52;
	cdoAtlanticCanada=9;
	cdoBrisbane=18;
	cdoKrasnoyarsk=64;
	cdoTonga=67;
	cdoMelbourne=57;
	cdoEkaterinburg=58;
	cdoMidAtlantic=30;
	cdoPerth=73;
	cdoHarare=50;
	cdoHawaii=15;
	cdoHobart=42;
	cdoMagadan=41;
	cdoArab=74;
	cdoAlaska=14;
	cdoSeoul=72;
	cdoDarwin=44;
	cdoEastern=10;
	cdoMidwayIsland=16;
	cdoCapeVerde=53;
	cdoIslamabad=47;
	cdoAthens=7;
	cdoTokyo=20;
	cdoRangoon=61;
	cdoAdelaide=19;
	cdoAbuDhabi=24;
	cdoCaracas=33;
	cdoWellington=17;
	cdoBangkok=22;
	cdoBuenosAires=32;
	cdoCaucasus=54;
	cdoSaskatchewan=36;
	cdoCentralAmerica=55;
	cdoSantiago=65;
	cdoNepal=62;
	cdoIsrael=27;
	cdoKabul=48;
	cdoHelsinki=59;
	cdoArizona=38;
	cdoMonrovia=31;
	cdoSarajevo=2;
	cdoSriLanka=66;
	cdoAlmaty=46;
	cdoUTC=0;
	cdoCairo=49;
	cdoDhaka=71;
	cdoGMT=1;
	cdoParis=3;
	cdoBerlin=4;
	cdoIrkutsk=63;
	cdoEasternEurope=5;
	cdoEniwetok=39;
	cdoPrague=6;
	cdoBrasilia=8;
	cdoBogota=35;
	cdoCentral=11;
	cdoEastAfrica=56;
	cdoMountain=12;
	cdoSingapore=21;
	cdoPacific=13;
	cdoVladivostok=68;
	cdoMoscow=51;
	cdoMexicoCity=37;
	cdoTaipei=75;
	cdoGuam=43;
	cdoInvalidTimeZone=78;
	cdoBombay=23;
	cdoNewfoundland=28;
	cdoSydney2000=76;
	cdoAzores=29;
	cdoYakutsk=70;
	cdoBaghdad=26;
	cdoBeijing=45 
	/*end intellisense*/
	};
	
	cdoNNTPProcessingField={
	/*intellisense(com.smtp.cdoNNTPProcessingField)*/ 
	cdoProcessModerator=4;
	cdoPostMessage=1;
	cdoProcessControl=2 
	/*end intellisense*/
	};
	
	cdoSensitivityValues={
	/*intellisense(com.smtp.cdoSensitivityValues)*/ 
	cdoSensitivityNone=0;
	cdoPrivate=2;
	cdoCompanyConfidential=3;
	cdoPersonal=1 
	/*end intellisense*/
	};
	
	cdoConfigSource={
	/*intellisense(com.smtp.cdoConfigSource)*/ 
	cdoOutlookExpress=2;
	cdoIIS=1;
	cdoDefaults=-1 
	/*end intellisense*/
	};
	
	cdoMessageStat={
	/*intellisense(com.smtp.cdoMessageStat)*/ 
	cdoStatBadMail=3;
	cdoStatSuccess=0;
	cdoStatAbortDelivery=2 
	/*end intellisense*/
	};
	
	cdoDSNOptions={
	/*intellisense(com.smtp.cdoDSNOptions)*/ 
	cdoDSNSuccess=4;
	cdoDSNDefault=0;
	cdoDSNNever=1;
	cdoDSNSuccessFailOrDelay=14;
	cdoDSNDelay=8;
	cdoDSNFailure=2 
	/*end intellisense*/
	};
	
	cdoImportanceValues={
	/*intellisense(com.smtp.cdoImportanceValues)*/ 
	cdoHigh=2;
	cdoLow=0;
	cdoNormal=1 
	/*end intellisense*/
	};
	
	cdoMHTMLFlags={
	/*intellisense(com.smtp.cdoMHTMLFlags)*/ 
	cdoSuppressNone=0;
	cdoSuppressImages=1;
	cdoSuppressAll=31;
	cdoSuppressFrames=4;
	cdoSuppressStyleSheets=16;
	cdoSuppressBGSounds=2;
	cdoSuppressObjects=8 
	/*end intellisense*/
	};
	
	cdoEventStatus={
	/*intellisense(com.smtp.cdoEventStatus)*/ 
	cdoSkipRemainingSinks=1;
	cdoRunNextSink=0 
	/*end intellisense*/
	};
	
	cdoPostUsing={
	/*intellisense(com.smtp.cdoPostUsing)*/ 
	cdoPostUsingPort=2;
	cdoPostUsingPickup=1
	/*end intellisense*/
	};
	
	cdoPriorityValues={
	/*intellisense(com.smtp.cdoPriorityValues)*/ 
	cdoPriorityNonUrgent=-1;
	cdoPriorityUrgent=1;
	cdoPriorityNormal=0
	/*end intellisense*/
	}
	
	//常量定义结束 CDO.Message;

}

 
/**intellisense()

!smtp.from = 发件人
!smtp.to = 收件人
!smtp.reply = "Another" <another@example.com>
!smtp.server = smtp服务器
!smtp.username = 用户名
!smtp.password = 密码
!smtp.subject = 邮件标题
!smtp.html = html邮件内容
!smtp.text = 文本邮件内容
!smtp.gethtml("__/*请输入html文件地址*/")  = html邮件内容
!smtp.addfile("__") = 添加附件，支持多参数
!smtp.port = smtp端口
!smtp.authenticate = 认证设置\n默认值为com.smtp.cdoAuthentication.cdoBasic
!smtp.timeout = 超时值，以秒为单位
!smtp.sendusing = 发送方式
!smtp.cc = 抄送
!smtp.bcc = 密送
!smtp.ssl = 是否支持SSL
?com.smtp = !smtp.
end intellisense**/
