SoFunction
Updated on 2025-03-09

Share solutions for sending emails with garbled attachments

Specific usage of Jamil sending emails:

First, we need to download it firstcomponent, then add a reference to using jmail, and then register it on the machine or server

Copy it to the server's system32 directory, start - run - cmd - enter regsvr32, register successfully, and then write the code

The code is as follows (method)

Copy the codeThe code is as follows:

using jmail;
    protected void sendMail(String sender, String senderMail, String receiver, String subject, String content)
    {

        jmMessage = new ();

//Set the character set

        = "gb2312";

//Sender's email address

        = senderMail;

//Sender's name

        = sender;

//Set the theme

        = subject;

//Set content

        = content;

// Set up the recipient's email address

        (receiver, "", "");

// Set the username and password for login email

        = "ss";

        = "ss";

//Set the smtp server address

        if (("smtp.", false))
        {

("<script>alert('Send Successfully')</script>");

        }

        else

("<script>alert('Send failed')</script>");

    }

The above is the specific usage of Jmail!

I want to put an attachment as follows

Copy the codeThe code is as follows:

(“c:”)
(“”,TRUE)

The result shows 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-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:

I found a solution online:

Copy the codeThe code is as follows:

AddAttachment(FileName, isInline, ContentType) :

String adds a file-type attachment to the email. If the Inline property is set to true, this attachment is an embeddable attachment. Use the addAttachment() method to return the content id, which is very useful when sending HTML messages.

example:

Copy the codeThe code is as follows:

(“c:”)
(“”,TRUE)

Embeddable accessories

(bstrURL, bstrAttachAs, isInline, bstrAuth) : String Download the file from the specified URL and add 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 property is set to true, this attachment is an embeddable attachment. The ddAttachment() method can return the content id, which is very useful when sending HTML messages. The last parameter is optional and is used when the server requires authentication.

example

Copy the codeThe code is as follows:

(“”,””)
””, “”,false, “myUserName:myPassword”)””,””,true )

After testing, it seems that it has nothing to do with the two methods. Later, someone said on the Internet that they removed the ="text/html" setting (just don't set the ContentType property). After trying it, it was really successful.