Jmail sends email with attachments to share spam solutions
- 2020-11-03 22:04:37
- OfStack
Jamil How to send email:
First, we download the components of Jamil.dll, add a reference to using jmail, and then register 1 more times either locally or on the server
Copy jmail.dll to the server's system32 directory, start - run -cmd- enter regsvr32 jmail.dll, register successfully, and then write the code
The code is as follows (method)
using jmail;
protected void sendMail(String sender, String senderMail, String receiver, String subject, String content)
{
jmail.MessageClass jmMessage = new jmail.MessageClass();
// Set the character set
jmMessage.Charset = "gb2312";
// E-mail address of sender
jmMessage.From = senderMail;
// Name of sender
jmMessage.FromName = sender;
// Set the theme
jmMessage.Subject = subject;
// Set the content
jmMessage.Body = content;
// Set the recipient mailbox
jmMessage.AddRecipient(receiver, "", "");
// Set the username and password of the login mailbox
jmMessage.MailServerUserName = "ss";
jmMessage.MailServerPassWord = "ss";
// Set up the smtp Server address
if (jmMessage.Send("smtp.163.com", false))
{
Response.Write("<script>alert(' Send a success ')</script>");
}
else
Response.Write("<script>alert('www.ofstack.com Send failure ')</script>");
}
Here's how Jmail is used!
I would like to put an attachment as follows
jmail.AddAttachment( " c:autoexec.bat " )
jmail.AddAttachment( " myImage.gif " ,TRUE)
The result is the following 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-ES88en-ES89en: base64 ES91en-ES92en: =? GB2312? Q? 12d95384-576f-424f-bf15-f8e2397e2791=2EJPG? = Content-Disposition: inline; filename = = "? GB2312? Q? 12d95384-576f-424f-bf15-f8e2397e2791=2EJPG? = "Content - ID:
I found a solution online:
AddAttachment(FileName, isInline, ContentType) :
String adds a file type attachment to a message. If the Inline attribute is set to true, the attachment is an embeddable attachment that USES the addAttachment() method to return content id, which is very useful when sending HTML emails.
Ex. :
jmail.AddAttachment( " c:autoexec.bat " )
jmail.AddAttachment( " myImage.gif " ,TRUE)
Embeddable attachments
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. If the Inline attribute is set to true, the attachment is an embeddable attachment. Using the ddAttachment() method, content id is returned, which is very useful when sending HTML emails. The last parameter is optional and is used when the server needs to authenticate.
case
jmail.AddURLAttachment( " w3jmail4.exe " , " w3jmail4.exe " )
jmail.AddURLAttachment " w3jmail4.exe " , " w3jmail4.exe " ,false, " myUserName:myPassword " )jmail.AddURLAttachment " dimaclogo.gif " , " dimaclogo.gif " ,true )
I tested it for 1, and it doesn't seem to have anything to do with the two methods. Later on the Internet, someone said that Message.ContentType = "text/html" setting to remove (is not to set the ContentType attribute), tried 1, but really sent the success