Summary (7) - Using Jmail to send and receive mail

xiaoxiao2021-03-17  206

Summary (7) - Using Jmail to send and receive mail

Squire: Terrylee

One. Send an email with Jmail

1

/ ** /

///

2 /// Use JMail to send mail 3 ///

4

Private

Void

Sendmailbyjmail ()

5

{6 / ** //// Establishment Seated 7 Jmail.MessageClass OjmailMailMersage = New Jmail.MersageClass (); 8 9 / ** ///////////bit 10 OJMailMAGE.CHARSET = "GB2312"; 1112 / ** //// The encoding format of the attachment 13 ojmailMessage.Encoding = "base64"; 14 ojmailMessage.contentType = "text / html"; 1516 / ** /// Whether to encode the letter into ISO-8859-1 character set 17 Ojmailmessage.isoEncodeHeaders = false; 1819 / ** //// Priority 20 OJmailMAESSAGE.PRIORITY = Convert.Tobyte (1); 21 22 / ** //// Transfer Email Address 23 OJMailMailMailMailMailMailMailMailMailMailMailMailMailMailMailMailMailMailMailMailMailMailMailMailMailMailMailMailMailMAILMAGE.FROM = TXTEMAIL.TEXT. Trim (); 24 25 / ** //// Send a name 26 ojmailMessage.FromName = txtname.text.trim (); 2728 / ** //// Mail Topic 29 OJMailMAGESSAGE.SUBJECT = TXTSUBJECT.TEXT.TRIM ); 3031 / ** //// Authenticated username 32 ojmailMAGE.mailServerUserName = txtsmtpuser.text.trim (); 3334 / ** //// user password 35 ojmailmessage.mailServerPassword = txtsmtppwd.text.trim () ; 3637 / ** //// Add a recipient, the additive and delayed people's adding and the method are the same, but use addRecipientcc and RecipientBCC 38 /// If you need to add multiple receipts People, repeat the following statements. Add multiple copies of multiple copies, 39 ojmailmessage.addrecipient (txtreciver.text.trim (), "" ""); 40 if (""! = Upfile.postedfile.filename) 41 {42 string attpath = Upfile.postedFile.FileName; 43 ojmailmessage.addattachment (@ attpath, true, attpath.substring (attpath.lastindexof (".") 1, 3)); // Add Acne 44} 4546 / ** //// Email content 47 OJMailMessage.Body = txtcontent.text.trim (); 4849 if (txtsmtserver.text.trim (), false) 50 {51 Response.write ("Send Success!"); 52} 53 Else54 {55 response.write ("Send failed, please check the settings of the mail server!"); 56} 5758 OJmailMAILMESSAGE = NULL; 59} 60

two. Receive mail with Jmail

1

/ ** /

///

2 /// Using JMail Receive Mail 3 /// 4

Private

Void

Recivebyjmail ()

5

{6 / ** //// Establishment Mail object 7 jmail.pop3class popmail = new pop3class (); 8 9 / ** //// Establishment mail information interface 10 jmail.Mersage MailMessage; 1112 / ** /// / Establish an attachment clip 13 jmail.attachments atts; 1415 / ** //// Establish an attachment interface 16 jmail.attachment att; 1718 try19 {20 popmail.connect (txtpopuser.text.trim (), txtpoppwd.text.trim. ), Txtpopserver.text.trim (), convert.TOINT32 (TXTPOPPOPPOPPORT.TEXT.TRIM ())); 21 22 / ** / //// If you receive a message 23 if (0

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

New Post(0)