Use of jmail. dll

Source: Internet
Author: User
Tags nntp server rfc822 all mail mail account

Configuration environment:. NET Framework 1.1, imai8.02, w3jmail4.3

Implementation process:

Unlike jmail in ASP, server. Createobject ("jmail. Message") can be used directly. In the. NET environment, you need to set.

1. Install jmail4.3

2. Find jmail. dll (under program files/dimac/w3jmail4)

3. Run program files/Microsoft Visual Studio. NET/frameworksdk/bin/ildasm.exe (you can use the Visual Studio. NET 2003 command prompt ),

Format: tlbimp C:/program files/dimac/w3jmail4/jmail. dll/out: myjmail. dll/namespace: myjmail

After myjmail. dll is generated, copy it to the bin directory of the Web root directory. On the ASP. NET page, use this method to reference:

It is easy to send emails using jmail. The following code is used:

Using jmail;

Private void page_load (Object sender, system. eventargs e) // not necessarily a load event
{

Jmail. Message jmessage = new jmail. messageclass ();
Jmessage. charset = "gb2312 ";

Jmessage. From = "help@gmail.com"; // mail address
Jmessage. fromname = Gmail comrade "; // sender

Jmessage. replyto = "help@gmail.com"; // reply address

Jmessage. Subject = "here is the title"; // mail title
Jmessage. addrecipient ("master@gmail.com", "", ""); // It is the recipient's address, and the following two parameters can be blank!

// Addrecipient (emailaddress, recipientname, pgpkey)
// Add a recipient to the email. Recipientname and pgpkey are optional, recipientname is the recipient's name, and pgpkey is encrypted to the email.

Jmessage. Body = "this is the mail content"; // The Mail content

Jmessage. mailserverusername = "*****"; // It is the user name used to log on to the mail account.
Jmessage. mailserverpassword = "*****"; // The password used to log on to the sender's mailbox.

Jmessage. Send ("10. 0. ****. **", false); // the IP address is the email server.
Response. Write ("email sent successfully! ");
Jmessage. Close ();

}

 

Describes in detail the W3 jmail Component Objects (12 ):

1. POP3 object

Attribute (or method)
Description

Connect (username, password, server, Port)
Connection to the POP3 server. The fracture is optional. The default value is 110.

Deletemessages ()
Delete all emails from the email server.

Deletesinglemessage (messageid)
Delete the email specified by messageid from the email server.

Disconnect ()
Close the connection to the email server.

Downloadheaders ()
Read all the mail headers from the mail server and pass them to the messages collection.

Downloadmessages ()
Read all emails from the email server.

Downloadsingleheader (messageid)
Read the specified mail header from the mail server and pass it to the messages collection.

Downloadunreadmessages ()
Read all unread emails from the email server.

2. Messages object

Attribute (or method)
Description

Clear ()
Clear all contents in the set and do not delete any emails from the email server.

Count (): integer
Number of records in the returned collection: I = messages. Count

Item (INDEX): pointer
Returns a message object. Set omsg = messages. Item (0)

3. Message object

Attribute (or method)
Description

Addattachment (filename, isinline, contenttype): String
Add a file attachment to the email. When isinline is set to true, the added attachment is an embedded attachment.

Addcustomattachment (filename, Data, isinline): String
Add a custom attachment to the email.

Addheader (xheader, value)
Add a custom email header X-header to the email.

Addnativeheader (header, value)
Add a mail header to the email.

Addrecipient (emailaddress, recipientname, pgpkey)
Add a recipient to the email. Recipientname and pgpkey are optional, recipientname is the recipient's name, and pgpkey is encrypted to the email.

Addrecipientbcc (emailaddress, pgpkey)
Add a BCC address.

Addrecipientcc (emailaddress, recipientname, pgpkey)
Add a CC address to the email.

Addurlattachment (bstrurl, bstrattachas, isinline, bstrauth): String
Download the file from the specified URL and add it as an email attachment. The bstrattachas parameter is used to change the file name added as an email attachment.

Appendbodyfromfile (filename)
Clear the mail body and use the content of the specified file as the mail body.

Appendhtml (text)
Append an HTML text from an email, as shown in the following example: Message. appendhtml ("

Appendtext (text)
Add a text body to the email.

Clear ()
Clearing all mail messages is an empty object.

Clearattachments ()
Clear the Attachment List. For example, message. clearattachments

Clearcustomheaders ()
Clear all custom mail headers.

Clearrecipients ()
Clear the list of all recipient addresses.

Close ()
Releases the cache used for connecting jmail to the email server ).

Decodeheader (header): String
Output a mail header message.

Extractemailaddressesfromurl (bstrurl, bstrauth)
Reads and adds a mail list from the specified URL.

Getmessagebodyfromurl (same as above)
Delete the body of the email and replace it with the content of the specified URL.

Keyinformation (keyidentifier): pointer
Returns a pgpkey object.

Loadfromstream (Stream)
Read data from the database stream. The database stream must comply with the rfc822 standard.

Logcustommessage (Message)
Add custom logs to the jmail log file. This function is valid only when the logging attribute is set to true.

NQ ()
Append the email to the sending queue for sending.

Parsemessage (messagesource)
Parse an email. The data stream must comply with the rfc822 format standard.

Savetostream (Stream)
Save the email to the data flow. The data flow must comply with the rfc822 format standard.

Send (MailServer, enque): Boolean
Send an email. The email server is a string describing the name or address of the email server. The user name and password are optional. The format for sending an authentication email is: User name: password @ email server.

Sendtonewsgroup (servername, newsgroup)
Use the specified NNTP server to send emails to the newsgroup. Separate multiple emails with commas.

About (): String
Set additional information.

Attachments (): pointer
Returns the attachment set of the email. Set attachments = message. attachments

Body (): String
Returns the body of the email. Response. Write (message. Body)

Bodytext (): String
Returns all text bodies. Response. Write (message. bodytext)

Charset (): String
Set the character set used by the email. The default is the US-ASCII, which is set to gb2312 if Chinese is supported.

Contenttransferencoding (): String
Set the email encoding. The default value is quoted-printable.

Contenttype (): String
Body type.

Date (): Date
Returns the email sending time.

Deferreddelivery (): Date
Set regular mail sending.

Encoding (): String
Set the default attachment encoding: base64 or quoted-printable

Encryptattachments (): Boolean
When it is set to true, all attachments are encrypted, and of course the compiler is available. The default value is true.

Errorcode (): integer
If message. Silent is set to true, this function contains an error number.

Erroemessage (): String
If message. Silent is set to true, this function contains an error description.

Erroesource (): String
If message. Silent is set to true, this function contains the error source.

From (): String
Returns or sets the sender's email address.

Fromname (): String
Returns or sets the sender's name.

Htmlbody (): String
Returns or sets the HTML part of the email body.

Isoencodeheaders (): Boolean
Whether the mail header uses iso-8859-1 encoding. (True by default)

Log (): String
When logging is true, this function returns the created log.

Logging (): Boolean
Whether to enable logging. Log is enabled when message. Logging is set to true.

Maildata (): String
Return the source code of the email.

Maildomain (): String
Sets the mail server used to send emails.

Mailserverpassword (): String
This function sets the logon password when the mail server uses SMTP mail authentication.

Mailserverusername (): String
This function sets the Logon account when the mail server uses SMTP mail authentication.

Mimeversion (): String
Declare the MIME Version. The default value is 1.0.

Mspickupdirectory (): String
Specifies the pickup folder location of the ms smtp service.

Pgpencrypt (): Boolean
When a message is sent using PGP and this attribute is set to true, the message is automatically encrypted.

Pgpsign (): Boolean
When a mail is sent using PGP and set to true, the mail is automatically signed.

Priority (): byte
Set mail Priority: 1, 2, and 3

Recipients (): pointer
Returns a set of recipients.

Recipientsstring (): String
Returns a set of recipients (read-only ).

Replyto (): String
Specify a reply address.

Silent (): Boolean
When it is set to true, the send () method ignores the error and does not return the error message to the operating system.

Simplelayout (): Boolean
When set to true, jmail does not add the mail header to the mail when sending the mail.

Size (): integer
The total number of bytes of the returned message.

Subject (): String
Set the mail title.

Text (): String
Returns the complete email content.

Version (): String
Return the jmal version information.

4. headers object

Attribute (or method)
Description

Getheader (headername): String
Returns the value of the specified header.

Text (): String
Returns the value of all mail headers.

5. Recipients object

Attribute (or method)
Description

Add (value)
Append a recipient to the collection.

Clear ()
Clear all records in the set.

Count (): integer
Returns the total number of recipients in the collection.

Item (INDEX): pointer
Returns a specified recipient in the set.

6. Recipient object

Attribute (or method)
Description

New (name, email, recipienttype): pointer
Create a recipient that can be added to the recipients set.

Email (): String
Returns the recipient's email.

Name (): String
Returns the recipient's name.

Retype (): integer
Return recipient mode (recipient to = 0, Cc = 1, bcc = 2 ).

7. attachments object

Attribute (or method)
Description

Add (Attachment)
Add an attachment to the collection.

Clear ()
Clear all attachments in the set.

Count (): integer
Returns the total number of attachments in the collection.

Item (INDEX): pointer
Returns the specified attachment in the collection.

8. Attachment object

Attribute (or method)
Description

New (filename, contenttype, data): pointer
Create an attachment that can be added to the attachments set. If the data value is specified, jmail creates a custom attachment with the data parameter as the content.

Savetofile (filename)
Save the attachment to the hard disk.

Contenttype (): String
Returned attachment type (contenttype)

Data (): String
Returns the content of the attachment.

Binarydata (): String
Returns the attachment content in binary mode.

Isinline (): Boolean
Returns true if the attachment is set to inline.

Name (): String
Returns the file name of the attachment.

Size (): integer
Returns the attachment size.

9. mailmerge object

Attribute (or method)
Description

Bulkmerge (recordset, enque, maildestination)
Use the mail template to merge all records and specify the pickuo folder or mail server to be used.

Expand (): pointer
Merge the mail template by referring to the method specified by the user (mailtemplate ).

Expandfromrecordset (recordset): pointer
Use mailtemplate to merge ADO objects.

Setdebugmode (testmailaddress, testcount)
Set mailmerge to test mode.

Item (variablenmae): String
Manually set merging parameters. Note: This function is not used to merge ADO data instances.

Mailtemplate (): pointer
Set a created message object, which will be used as a template for mail merge.

Mergeattachments (): Boolean
When this attribute is set to true, attachments are used as an option for mail merge.

10. pgpkeys object

Attribute (or method)
Description

Count (): integer
The total number of returned passwords.

Item (INDEX): pointer
Returns the pgpkey information object.

11. pgpkeyinfo object

Attribute (or method)
Description

Keycreatedate (): String
Returns the time when the email password was created.

Keyid (): String
Returns the ID of the password.

Keyuser (): String
Returns the username used to create the password.

12. speedmailer object

Attribute (or method)
Description

Enquemail (fromemail, recipientemails,

Subject, body, mspickupdirectory)
Add an email to the sending queue. Content, topic, and other data are transmitted through parameters of this method.

Sendmail (fromemail, recipientemails,

Subject, body, mailservers)
Send an email through SMTP. Content, topic, and other data are transmitted through parameters of this method.

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.