qqMail .NET component
qqMail is a SMTP, POP & NNTP .NET class component. We wrote this component to
enhance the functionality of native system.web.mail class,
and offer possibilities to use POP & NNTP.
System.web.mail is a .NET class used for email delivery. However, it has very limited functions.
For example, it does not support authentication,
can only send pure text email format while many developers like to use MINE multipart email format.
Besides enhancing functionality of email delivery, our SMTP class offers two advanced features.
1. Direct send. Our class can do a DNS lookup for email domain MX record and send email
directly to remote SMTP server. Email will arrive at destination inbox instantly.
2. Delivery verification. We verify each single sending to make sure email is delivered successfully,
otherwise we will return the error message.
POP & NNTP class can be used to develop
web based email application or news reader
system. qqMail.NET is free. Please check
our terms & conditions
for conditions to use our free components.
download now
Code example
qqMail SMTP class:
Send email in mine format
Dim HtmlBody As String = "<br><b>html body, this is</b><br>"
Dim TextBody As String = "your text body goes here."
Dim objMail As qqMail.qqSmtp = New qqMail.qqSmtp
objMail.Subject = "this is your order confirmation"
objMail.From = "guoqi@yoursite.com"
objMail.TextBody = TextBody
objMail.HtmlBody = HtmlBody
objMail.To = "test@test.com"
' direct send use DNS Mx record, sending without an external smtp server.
' if it failed, it will use SMTP server on property SmtpServer or
' default smtp server (127.0.0.1) as a backup to try again.
objMail.UseDirectSend = True
objMail.MailFormat = qqMail.qqSmtp.EnumMailFormat.mime
objMail.SendMail()
If objMail.isOk = True Then
' sending is ok
Else
' there is an error.
response.write(objMail.ErrDes)
End If
objMail = Nothing
qqMail POP class:
Receive emails from server.
Dim strServer As String = "mail.yourserver.com"
Dim strUser As String = "usernamehere"
Dim strPass As String = "password"
Dim objpop As qqMail.qqPop = New qqMail.qqPop
objpop.PopServer = strServer
objpop.PopUser = strUser
objpop.PopPass = strPass
objpop.Login()
' after login, pop server will scan mailbox and assign a id for each message in that inbox.
' message id starts from 1.
' property MaxMsgNr will be available after login, MaxMsgNr
is the max message id returned by server.
Dim MsgId As Integer = objPop.MaxMsgNr
Dim objMail As qqMail.MailMessage = New qqMail.MailMessage
objMail = objpop.PraseMsg(MsgId)
' now you have got the mail message content.
' do something to process that mail message.
' you can also use a loop to process all the message.
Dim strFrom as string = objMail.From
Dim strSubject as string = objMail.Subject
Dim strTextBody as string = objMail.TextBody
Dim strHtmlBody as string = objMail.HtmlBody
Dim strContentType as string = objMail.ContentType
....
' if there is an attachment, you can look to save that attachment.
If objMail.HasAttachment = True Then
Dim i As Integer
For i = 0 To objMail.AttachmentList.Count - 1
Dim objAtt As qqMail.Attachment = objMail.AttachmentList(i)
objAtt.SaveAs("e:\tmp")
Next
End If
objpop.Del(MsgId)
objpop.logout()
qqMail NNTP class:
retrieve message from USENET server.
Dim GroupFullName As String = "microsoft.public.xml"
Dim NewsServer As String = "news.microsoft.com"
Dim objNNTP As qqMail.qqNNTP = New qqMail.qqNNTP
objNNTP.strGroup = GroupFullName '
objNNTP.strServer = NewsServer
objNNTP.UserName = ""
objNNTP.Password = ""
objNNTP.TimeOut = 30
Try
objNNTP.Connect()
objNNTP.goGroup()
Catch ex As Exception
' connection to server failed.
' can add log here.
' exit
End Try
If objNNTP.isOk = False Then
' when isok property is False, there might be an error
' e.g. login failed. try catch block will not return error when login failed.
' do something to log the error.
' addlog(objNNTP.ErrDes)
End If
' after goGroup command, news server will returns a stat of all messages in it
' and the range message id.
' property MaxNewsNr and MinNewsNr will be available after gogroup.
' now we try to check last 10 messages.
Dim MaxId As Integer = objNNTP.MaxNewsNr
Dim Last10 As Integer = objNNTP.MaxNewsNr - 10
If Last10 < objNNTP.MinNewsNr THEN
Last10 = objNNTP.MinNewsNr
END IF
Dim i As Integer
For i = Last10 To MaxId
Dim objNews As qqMail.NewsMessage = New qqMail.NewsMessage
objNews = objNNTP.PraseNews(i)
If objNNTP.isOk = True Then
' if isOk property return False, there might be an error.
' you can add your error handling when it is false.
' now objnews is avaliable for operation.
Dim strMsgBody As String = objNews.TextBody
'......
End If
objNews.InitClean()
objNews = Nothing
Next
objNNTP.Disconnect()
|