VB combined JMail send email (with accessories)

Source: Internet
Author: User
Tags trim

'----Send email
'----Jmail.dll can search the web for the next
Private Sub SendEmail ()

' Dim Sjmail as New jmail. SmtpMail
Dim Sjmail as Object
Dim Str as String
Dim Aryemail () as String
Dim I as Integer
Set Sjmail = CreateObject ("Jmail.smtpmail")

' My SMTP Server Address (uses default port=25)
Sjmail. serveraddress = "10.1.3.252" ' "<<address of your SMTP server>>"
Sjmail. ServerPort = 25

' My Name and Mail Address
Sjmail. Sender = "Erpadmin@mazen.com"
Sjmail. ReplyTo = "Erpadmin@mazen.com"

' Recipient Address and Name
str = getmailaddress ()
If str = "Then Exit Sub"
Aryemail = Split (str, ";")

' Receiver email, can be multiple
For i = 0 to UBound (aryemail)
If Trim (Aryemail (i)) > "Then Sjmail. AddRecipient Trim (Aryemail (i))
Next I

' Sjmail. AddRecipient "Abc@mazen.com"

' Compose message
Sjmail. Subject = "Report_data" title
Sjmail. Priority = 1
Sjmail. Body = "A010411_report_data" & Format (now, "yyyy-mm-dd") ' contents
Sjmail. AddAttachment "D:/a1.txt"
Sjmail. AddAttachment "D:/a2.txt"

' Send The Mail '
Sjmail. Execute

' Test for errors
If ERR <> 0 Then
MsgBox error$, vbcritical, "Mail Error"
End If

' Dispose Object
Set Sjmail = Nothing

End Sub

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.