Example of downloading attachments using java and javascript
In web development, you often need to develop the "Download" module. The following is a simple example.
On the server side, use java for development:
01
@ RequestMapping (value = "download.html", method = RequestMethod. GET)
02
Public void download (String resourceid, HttpServletRequest request, HttpServletResponse response ){
Smptpmail.port = 587; QQ user name, and authorization code smptpmail.credentials = new NetworkCredential ("8448xx4", "gsdahhe!"); Smptpmail.send (Objmailmessage); NetEase mailbox: (Has been tested successfully, PS.) I netease mailbox does not seem to have set the Stmap and authorization code, it seems that the account, password can be used directly) String txtfullpath = HttpContext.Current.Server.MapPath ("~/") [email protected] "show/xxx contract. txt"; Create an Attachment ob
Java mail sending program (can be sent to multiple addresses at the same time, can carry attachments), java mailMain Program for sending emailsImport java. util. Properties;Import common. util. Email_Autherticatorbean;Import javax. mail. Authenticator;Import javax. mail. internet. InternetAddress;Import org. apache. commons. lang. StringUtils;Import javax. mail. internet. MimeBodyPart;Import javax. mail. Multipart;Import javax. activation. FileDataSou
In web development, you often need to develop the "Download" module. The following describes how to download attachments using java and javascript. For more information, see web development, you often need to develop the "Download" module. The following is a simple example.
On the server side, use java for development:
@RequestMapping(value = "download.html", method = RequestMethod.GET) public void download(String resourceid, HttpServletRequest requ
Python allows you to send emails and attachments.
Today, I want to tell you how to send an email to python. I have to go to Baidu for additional official words. I still have a lot of documents to tell you the truth, so most people will not go to it. I will go back to the topic:
If the mac is not based on the dependent module, install it as follows:
If there is no error in the import module, the installation is successful.
Python sends an unknown MIME
Assume there are two servers: A and B, where A is a Web server (ip:192.123.1.1, a server for IIS publishers), and B is a file server (ip:192.123.2.2)
Create a shared folder under a disk in file Server B docshare, and create a user on that server, such as Docuser, and assign this user read and write access to the shared folder
The same user, such as Docuser, is also created in Web Server A, and the password must be consistent with the Docuser in B. and add user Docuser to the IIS_WPG use
();DataSource Source = new Filedatasource (attachment);Attachmentbodypart.setdatahandler (new DataHandler (source)); Online spread of the solution file name garbled method, in fact, with Mimeutility.encodeword can be very convenient to fixIt is important to use the following BASE64 encoded conversion to ensure that your Chinese attachment header name is not garbled when it is sentSun.misc.BASE64Encoder enc = new Sun.misc.BASE64Encoder ();Messagebodypart.setfilename ("=? GBK? B? "+ Enc.encode (A
Before downloading the attachment in IE, you need to clear the cache and encode the Chinese file name with urlencode. The following is a good example. if you need it, refer to the following:
1. clear the cache before downloading attachments in IE.
2. the Chinese file name must be URL encoded.
The code is as follows:
Header ("Pragma:"); // if it is not added, IE will prompt that the target host cannot be accessed.Header ("Cache-Control:"); // if i
Multipartemail email = new Multipartemail ();Email.setdebug (TRUE);Email.sethostname ("smtp.sina.com");Email.setauthentication ("Send mail Account", "Email login password");Email.setcharset ("UTF-8");try {Email.setfrom ("Send mail Account", "User name");Email.addto ("Accept email account", "username");Email.setsubject ("subject");Email.setmsg ("text");emailattachment ment = new Emailattachment ();Ment.setpath (absolute path of the attachment);Ment.setname (Mimeutility.encodetext ("The name of th
In a Linux system, messages can be sent with the Mail command, but when sent with an attachment, the attachment is always reported as too large an error. Without knowing how to configure Linux mail, I chose Python for sending messages with attachments.Import SmtplibFrom Email.mime.multipart import MimemultipartFrom Email.mime.text import MimetextFrom email.mime.application import mimeapplicationMail_host= "Smtp.exmail.qq.com" #设置服务器Mail_user= "#填写用户名" #用户名mail_pass= "#用户名对应的密码" #口令mail_postfix=
arrive at the B01 meeting room tomorrow 16:00 for a technical seminar. "See whether messages sent by mail programs are sent successfully through the Outlook clientKey code:Create a class Emailauthenticator and inherit from authenticator, and populate the user name and passwordView CodeCreate mail class to set message information:View CodeTest class:View CodeSend mail with an attachmentMailwithattachment:View CodeTest class:View CodeApplicationcontext.xml: Large ConfigurationView CodeSend mail w
In a Linux system, messages can be sent with the mail command, but when sent with an attachment, the attachment is always reported as too large an error. Without knowing how to configure Linux mail, I chose Python for sending messages with Attachments.Import SmtplibFrom Email.mime.multipart import MimemultipartFrom Email.mime.text import MimetextFrom email.mime.application import mimeapplicationmail_host= "smtp.exmail.qq.com" #设置服务器mail_user= "#填写用户名" #用户名mail_pass= "#用户名对应的密码" #口令mail_postfix=
This article mainly introduces the solution of garbled Chinese names for PHP attachment downloading, analyzes the causes of garbled Chinese characters and the corresponding encoding conversion methods, which has some reference value, for more information about how to download PHP attachments, see the example below. We will share this with you for your reference. The details are as follows:
In PHP, if the file name to be downloaded is called Chinese,
Best Solution for saving file attachments in the Database System
By http://blog.csdn.net/jacklondon
Http://blog.csdn.net/jacklondon/archive/2010/10/26/5966558.aspx
Many people develop database systems. I believe many people have encountered the problem of saving files in the database. Common database systems all have field types such as blob, image, and binary to handle this problem.
Software developers will encounter this problem and be trapp
OAF doesn ' t readily expose the Controller Servlet ' s HttpRequest and HttpResponse objects so your need to extract it from th E Oapagecontext object via:HttpServletResponse response = (httpservletresponse) pagecontext.getrenderingcontext (). Getservletresponse ();Once you get the response object to could already manipulate its outputstream. Public voiddownloadFile (Oapagecontext pagecontext) {httpservletresponse respons E=(HttpServletResponse) Pagecontext.getrenderingcontext (). Getservletresp
())));
}
/***************************************
** Adds a file to the list of attachments.
***************************************/
Function add_attachment ($ file, $ name = '', $ c_type = 'application/octet-stream '){
$ This-> parts [] = array ('body' => $ file,
'Name' => $ name,
'C _ type' => $ c_type );
}
/***************************************
** Builds an embedded image part of
** Html mail.
Step 1,System]-[basic system parameters]. In the core settings, "(yes/no) supports multiple sites, after this option is enabled, the attachment, column connection, and arclist content enable absolute URL "option is enabled.Step 2,Bind a second-level domain name in topic settings. In the system background [core]-[website topic management], edit the information for the section "webpage template. In the advanced options section, we first enable multi-site support and bind the domain
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.