ASP sends an email with Jmail, CDO [Reposted http:www.blueidea.comtechprogram2003721.asp]

xiaoxiao2021-03-06  60

Disclaimer: Reposted this article is just to learn purposes, and write a web page in the future, you can directly copy, easy to use. ASP sends an email with Jmail, CDO

Author: Shuai frog Time: 2003-9-12 Document Type: Original from: blue over a period of time before there is a simple JMAIL sent a mail message code, today put the code to do a specific comments, and adds The other two formats, and raise a few simple examples:

The first is the core code of jmail.smtpmail:

<%

Set jmail = server.createObject ("jmail.smtpmail") 'Create a Jmail object

Jmail.silent = true 'jmail does not throw exception error, the return value is false and true

Jmail.logging = true 'Enables logging

Jmail.Charset = "GB2312" code code is Simplified Chinese

Jmail.contentType = "text / html" "The format of the message is HTML

Jmail.Serveraddress = "Server Address" "Servers sending mail

Jmail.addrecipient email 'recipient

Jmail.SenderName = "sendername" 'Mail sender's name

Jmail.Sender = "email address" "email address" mail sender's email address

Jmail.Priority = 1 'email emergency procedure, 1 is the fastest, 5 is the slowest, 3 is default

Jmail.subject = "mail subject" 标 邮 邮 邮

Jmail.Body = "mail body" "content"

JMail.AddrecipientBCC Email 'Pixabay Address

Jmail.addrecipientcc email 'email Cc

Jmail.execute () 'Executing Mail Send

Jmail.close 'Close the email object

%>

[Ctrl A All Choose and Copy]

W3 Jmail4.3 Components Redes its internal structure - Use the Message object instead of the original single object Jmail.smtpmail sends mail, some methods require authentication (such as 163, yahoo et al), can solve the following method: <%

Set jmail = server.createObject ("jmail.message") 'Establish an object that sends an email

Jmail.silent = True 'masked exception error, return false with true two value J

Mail.logging = true 'Enables mail logs

Jmail.Charset = "GB2312" message text code is national standard

Jmail.conteType = "text / html" "The format of the message is HTML format

Jmail.addrecipient email 'mail recipient's address

Jmail.From = "email from for sender" 'sender's E-mail address jmail.mailserverunaMe = "username of email" User name required to log in to the mail server

Jmail.mailServerPassword = "password of email" "logged in the password required for the mail server

Jmail.subject = "mail subject" 标 邮 邮 邮

Jmail.Body = "mail body" "content"

Jmail.Proity = 1 'email emergency procedure, 1 is the fastest, 5 is the slowest, 3 is the default value

Jmail.send ("Server Address") 'Executing Mail Send (via mail server address)

Jmail.close () 'Close object

%> [Ctrl A All Choose and Copy]

Tell the method of sending information from Microsoft's own CDONTS components: <%

Set cdomail = server.createObject ("cdonts.newmail") 'Establishing a mail object

CDomail.subject = "mail subject" "mail title

CDomail.from = "sender's mail" 'sender's address

CDomail.to = "email will from" 'recipient's address

cdomail.body = "mail body" "content"

CDOMAIL.SEND 'execution send

%> [Ctrl A All Choose and Copy] This method is the easiest, and it also brings certain problems, that is, there are very few servers will open this service!

We write procedures, in general, it is to say to code modularization, so convenient maintenance, it is also convenient to transplant. Therefore, I am here to write this email into a subsidy. When the call is called, I can call directly (of course, if you are happy to write a function, it is ok, this is mainly to see personal interest): <%

'Parameter Description

'Subject: Email Title

'MailDress: Address server address, such as SMTP.163.com

'Email: Recipient email address

'Sender: sender name

'Content: Mail content

'FROMER: sender's email address

Sub SendAction (Subject, Mailaddress, Email, Sender, Content, Fromer)

Set jmail = server.createObject ("jmail.smtpmail") 'Create a Jmail object

Jmail.silent = true 'jmail does not throw exception error, the return value is false and true

Jmail.logging = true 'Enables logging

Jmail.Charset = "GB2312" code code is Simplified Chinese

Jmail.conteTtype = "text / html" "The format of the message is HTML Jmail.Serveraddress = Mailaddress' sends a mail server.

Jmail.addrecipient email 'recipient

Jmail.Sendername = sender 'email sender's name

Jmail.Sender = Fromer 'mail sender's email address

Jmail.Priority = 1 'email emergency procedure, 1 is the fastest, 5 is the slowest, 3 is default

Jmail.Subject = Subject 'title

Jmail.body = content 'message

'Since I haven't used it to copy and copy, this two sentences are blocked, if you need it, you can restore it here.

'Jmail.AddrecipientBCC Email' Pixabay Address

'jmail.addrecipientcc email' email Cc

Jmail.execute () 'Executing Mail Send

Jmail.close 'Close the email object

End Sub

'An example of calling this SUB

DIM STRSUBJECT, STREMAIL, STRMAILADRESS, STRSENDER, STRCONTENT, STRFROMER

STRSUBJECT = "This is a test message sent by JMAIL"

StrContent = "Jmail Components Send Test Success!"

stremail = "runbing@eyou.com"

Strfromer = "runbing@eyou.com"

StrmailadDress = "mail.ubbcn.com"

Call SendAction (STRSUBJECT, STRMAILADRESS, STREMAIL, STRSENDER, STRCONTENT, STRFROMER)

%> [Ctrl A All Choose and Copy] The above is a rough insight that I am in the email code, forget everyone!

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

New Post(0)