Mail solution based on .NET

zhaozj2021-02-17  46

Mail solution based on .NET

I started using the .NET's System.Web.mail message component, I feel very easy to use, and simple. But later found that SMTPMail, SMTPMail, does not support SMTP certification, and many of many SMTP servers do not only need to log in to verification, and also verify Mail from (such as 263), if the username and the username used do not match the username does not send. Another is the information parsing problem of POP3 mail, such as analyzing Chinese. Summarize the mail problem is 2 questions:

First, SMTP authentication, the second is the information parsing of POP3 mail.

The above two problems are also the core issues that MS did not provide part. I also asked MS experts, and they didn't give me any reply to Mail solutions. There are also many masters on the Internet to dedicate their own source, but the two problems mentioned have never been (or I didn't find online). Look at some coders are now looking for this, so, or provide my solution to everyone, just give you a reference.

With Jmail Components: You can solve the above two problems, and the JMail component (Ver 4.3) provides authentication, and the received information parsing can be well resolved!

Here are two web service methods

'Send Email

Public Function Jmail_send (Byval FromemailAddress as String, _

ByVal Toemailaddress as string, _

Byval ccemailaddress as string, _

Byval bccemailaddress as string, _

Byval Subject As string, _

Byval body as string, byval mailserver as string) as boolean

DIM Email as new jmail.Message ()

Email.logging = TRUE

Email.silent = TRUE

'Email.mailserverusername = "" "' SMTP server username

'Email.mailserverpassword = "" "" SMTP server password

Email.From = FromemailAddress

Email.subject = SUBJECT

Email.Body = Body

Email.AddRecipient (TOEMAILADDRESS)

If Email.send (MailServer) THEN

Return True

Else

Return False

END IF

END FUNCTION

'Receive Email

Public Function Jmail_receivemail (Byval UserName As String, _

Byval Password As String, Byval MailServer As String) As Boolean

DIM Email As new jmail.pop3 ()

DIM msg as new jmail.Message ()

Email.Connect (username, password, mailserver, 110)

IF email.count ()> 0 THEN

Msg = email.Messages.Item (1)

Debug.write (msg.fromname)

Debug.write (msg.subject)

Debug.write (msg.date) Debug.write (msg.body)

Return True

END IF

Email.disconnect ()

END FUNCTION

The above code is to transmit and receive an original shape of the mail code using JMail. You can expand on this basis. Jmail provides powerful mail sending and processing, you don't have to pay too long, you can do all the needs, isn't it good? Of course, you can also write components yourself. Receive emails can be handled by IMPORTS System.Convert to perform Base 64 processing, decoding! I hope everyone can find solutions for yourself!

Author: Li Honggen Lihonggen0

Personal column: http://www.9cbs.net/develop/author/netauthor/lihonggen0/

Welcome to advice!

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

New Post(0)