A class that emails (implementation with CDO)

xiaoxiao2021-03-06  50

Public class sendmail {} // Send a normal text Email method entry // from: send mail address to: recipient email address // fromName: Sender name Toname: Received Name // Subject: Letter Theme // body: Mail Text Public Int Se (String str Conlicle, string strcontent) {try {cdo.message omsg = new cdo.Message (); omsg.from = "administrator@innosis.com.cn"; omsg. To = strTO; // "atenshen@innosis.com.cn"; omsg.subject = start = "; //" mailtest "; omsg.htmlbody =" s " strcontent " ";

CDO.ICONFIGURATION ICONFG = omsg.configuration; adoDb.fields ofields = iconfg.fields; Ofields ["http://schemas.microsoft.com/cdo/configuration/sendusing] .value = 2; Ofields [" http: // schemas.microsoft.com/cdo/configuration/sendemailaddress"].Value="JamesWang "; // sender mail oFields [" http://schemas.microsoft.com/cdo/configuration/smtpaccountname "] .Value =" JamesWang " ; // Email Account Ofields ["http://schemas.microsoft.com/cdo/configuration/sendusername] .Value =" jameswang "; Ofields [" http://schemas.microsoft.com/cdo/configuration/sendpassword "] .Value =" 531713wt "; Ofields [" http://schemas.microsoft.com/cdo/configuration/smtpauthentic "] .value = 1; // value = 0 represents an Anonymous authentication method (no verification) // Representative Basic authentication value = 1 (using basic (clear-text) authentication. // The configuration sendusername / sendpassword or postusername / postpassword fields are used to specify credentials.) // value = 2 Representative NTLM authentication (Secure Password authentication in Microsoft Outlook Express) Ofields ["http:// SCH Emas.microsoft.com/cdo/configuration/languagecode"].value=0x0804; ouelds ["http://schemas.microsoft.com/cdo/configuration/smtpserver] .value =" 192.168.161.32 "; Ofields.Update (); Omsg.bodypart.charset = "gb2312"; omsg.htmlbodypart.charset = "GB2312";

omsg.send (); omsg = null;} catCH (Exception e) {return -1; throw e;} return 0;}}

转载请注明原文地址:https://www.9cbs.com/read-115868.html

New Post(0)