JMail send mail and with accessories garbled solution sharing _ practical skills

Source: Internet
Author: User
Tags net send

Jamil the specific use of sending mail:

First, we need to download the Jamil.dll component, then add the reference using JMail, and then register on this machine or on the server

Copy the Jmail.dll to the server's System32 directory, start-run-cmd-enter regsvr32 jmail.dll, register successfully, and write code

The code is as follows (method)

Copy Code code as follows:

Using JMail;
protected void SendMail (string sender, String sendermail, string receiver, string subject, string content)
{

JMail. MessageClass jmmessage = new JMail. MessageClass ();

Setting the character set

Jmmessage.charset = "gb2312";

Sender's mailbox address

Jmmessage.from = Sendermail;

Sender Name

Jmmessage.fromname = sender;

Set a Theme

Jmmessage.subject = Subject;

Set content

Jmmessage.body = content;

Set up a recipient mailbox

Jmmessage.addrecipient (receiver, "", "");

Set the username and password of the login mailbox

Jmmessage.mailserverusername = "ss";

Jmmessage.mailserverpassword = "ss";

Set SMTP server address

if (Jmmessage.send ("smtp.163.com", false)
{

Response.Write ("<script>alert (' send Success ') </script>");

}

Else

Response.Write ("<script>alert (' www.jb51.net send failure ') </script>");

}

Above is the concrete usage of JMail!

I would like to place an attachment as follows

Copy Code code as follows:

JMail. AddAttachment ("C:autoexec.bat")
JMail. AddAttachment ("Myimage.gif", TRUE)

The result appears as follows error

This is a multipart message in MIME format. --NEXT_BM_AEB3968967D044DC9E208D04088C60B4 content-type:text/html; charset= "Gb2312″content-transfer-encoding:quoted-printable sdfdd--next_bm_aeb3968967d044dc9e208d04088c60b4 Content-type:application/octet-stream; Name= "=? GB2312? q?12d95384-576f-424f-bf15-f8e2397e2791=2ejpg?= "content-transfer-encoding:base64 Content-Description: =? GB2312? Q?12d95384-576f-424f-bf15-f8e2397e2791=2ejpg?= Content-disposition:inline; Filename= "=? GB2312? Q?12d95384-576f-424f-bf15-f8e2397e2791=2ejpg?= "Content-id:

Find a solution online:

Copy Code code as follows:

AddAttachment (FileName, IsInline, ContentType):

String adds a file-type attachment to the message. If the inline property is set to True, this attachment is an embeddable attachment, and using the AddAttachment () method returns the content ID, which is useful when sending an HTML message.

Cases:

Copy Code code as follows:

JMail. AddAttachment ("C:autoexec.bat")
JMail. AddAttachment ("Myimage.gif", TRUE)

Attachments that can be embedded

2.AddURLAttachment (bstrURL, Bstrattachas, IsInline, Bstrauth): string downloads the file from the specified URL and adds it as an attachment. The second parameter "Attachas" is used to change the file name of the file added as an attachment, and if the inline property is set to True, the attachment is an embeddable attachment, and the Ddattachment () method returns the content ID, which sends the HTML is very useful for messages. The last parameter is optional and is used when the server requires authentication.

Cases

Copy Code code as follows:

JMail. Addurlattachment ("W3jmail4.exe", "W3jmail4.exe")
JMail. Addurlattachment "W3jmail4.exe", "W3jmail4.exe", False, "Myusername:mypassword") JMail. Addurlattachment "Dimaclogo.gif", "Dimaclogo.gif", True)

Measured, as if it had nothing to do with two methods. Later on the internet, someone said the Message.contenttype = "text/html" Settings to remove (is not to set the ContentType property), tried, and really sent a successful

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.