mime

Maximum length of a MIME Content-Type header field?

百般思念 提交于 2019-11-30 14:26:32
问题 I'm just designing the schema for a database table which will hold details of email attachments - their size in bytes, filename and content-type (i.e. "image/jpg", "audio/mp3", etc). Does anybody know the maximum length that I can expect a content-type to be? 回答1: I hope I havn't misread, but it looks like the length is max 127/127 or 255 total . RFC 4288 has a reference in 4.2 (page 6): Type and subtype names MUST conform to the following ABNF: type-name = reg-name subtype-name = reg-name

how to tell if a string is base64 or not

淺唱寂寞╮ 提交于 2019-11-30 14:13:24
I have many emails coming in from different sources. they all have attachments, many of them have attachment names in chinese, so these names are converted to base64 by their email clients. When I receive these emails, I wish to decode the name. but there are other names which are not base64. How can I differentiate whether a string is base64 or not, using the jython programming language? Ie. First attachment: ------=_NextPart_000_0091_01C940CC.EF5AC860 Content-Type: application/vnd.ms-excel; name="Copy of Book1.xls" Content-Transfer-Encoding: base64 Content-Disposition: attachment; filename=

Display ASP.NET generated pdf byte[] to web page without saving the file

只谈情不闲聊 提交于 2019-11-30 14:01:47
问题 I'm using iTextSharp for generating a pdf. I can save the PDF file from the PDF byte[]. byte[] outputPDF = cnt.CreateBreakPDF(); File.WriteAllBytes(pdfOutPutPath, outputPDF); What is the best way to display the output byte[] to a web page? I want to show the PDF inside a div in my page. Not the PDF as a full response. I've seen answers for MVC, but I'm using ASP.NET Web Application. Is there a better way than using HTTP handlers to do so? I don't want to send all the details for creating PDF

How do I use Python 3.2 email module to send unicode messages encoded in utf-8 with quoted-printable?

家住魔仙堡 提交于 2019-11-30 13:51:47
I want to send email messages that have arbitrary unicode bodies in a Python 3.2 program. But, in reality, these messages will consist largely of 7bit ASCII text. So I would like the messages encoded in utf-8 using quoted-printable. So far, I've found this works, but it seems wrong: c = email.charset.Charset('utf-8') c.body_encoding = email.charset.QP m = email.message.Message() m.set_payload("My message with an '\u05d0' in it.".encode('utf-8').decode('iso8859-1'), c) This results in an email message with exactly the right content: To: someone@example.com From: someone_else@example.com Subject

Create and parse multipart HTTP requests in Python

别说谁变了你拦得住时间么 提交于 2019-11-30 13:07:49
I'm trying to write some python code which can create multipart mime http requests in the client, and then appropriately interpret then on the server. I have, I think, partially succeeded on the client end with this: from email.mime.multipart import MIMEMultipart, MIMEBase import httplib h1 = httplib.HTTPConnection('localhost:8080') msg = MIMEMultipart() fp = open('myfile.zip', 'rb') base = MIMEBase("application", "octet-stream") base.set_payload(fp.read()) msg.attach(base) h1.request("POST", "http://localhost:8080/server", msg.as_string()) The only problem with this is that the email library

Base64 decoding of MIME email not working (GMail API)

╄→гoц情女王★ 提交于 2019-11-30 12:50:11
I'm using the GMail API to retrieve an email contents. I am getting the following base64 encoded data for the body: http://hastebin.com/ovucoranam.md But when I run it through a base64 decoder, it either returns an empty string (error) or something that resembles the HTML data but with a bunch of weird characters. Help? I'm not sure if you've solved it yet, but GmailGuy is correct. You need to convert the body to the Base64 RFC 4648 standard. The jist is you'll need to replace - with + and _ with / . I've taken your original input and did the replacement: http://hastebin.com/ukanavudaz And

Display ASP.NET generated pdf byte[] to web page without saving the file

…衆ロ難τιáo~ 提交于 2019-11-30 09:21:22
I'm using iTextSharp for generating a pdf. I can save the PDF file from the PDF byte[]. byte[] outputPDF = cnt.CreateBreakPDF(); File.WriteAllBytes(pdfOutPutPath, outputPDF); What is the best way to display the output byte[] to a web page? I want to show the PDF inside a div in my page. Not the PDF as a full response. I've seen answers for MVC, but I'm using ASP.NET Web Application. Is there a better way than using HTTP handlers to do so? I don't want to send all the details for creating PDF as query string. I tried this in jsFiddle , and it works well in Chrome & FF, need to check on other

IE9 script response blocked due to mime type mismatch

好久不见. 提交于 2019-11-30 09:00:56
I use the following code snippet to load data from google fusion table as json. var fileref = document.createElement("script"); fileref.setAttribute("type", "text/javascript"); fileref.setAttribute("src", "http://tables.googlelabs.com/api/query?sql=select * from 588320&hdrs=false&jsonCallback=LoadTable"); Works great in IE8, FF, Chrome, but now IE9 doesn't know how to handle the callback because the response and mime types don't match. IE9 reports the following script error when using jsonCallback param because it doesn't like the mime type. SEC7112: Script from http://tables.googlelabs.com

ATTnnnnn.txt attachments when e-mail is received in Outlook

偶尔善良 提交于 2019-11-30 04:02:14
问题 I've written an SMTP client that sends e-mails with attachments. Everything's fine except that when an e-mail sent by my program is received by Outlook it displays two attachments - the file actually sent and a file with two characters CR and LF inside and this file has name ATT?????.txt. I've done search - found a lot of matches like this for similar problems and checked everything I could. Even more - I compared two emails - sent by my program and sent by Opera and I can't deduce the

MIMEMultipart, MIMEText, MIMEBase, and payloads for sending email with file attachment in Python

安稳与你 提交于 2019-11-30 02:06:38
Without much prior knowledge of MIME, I tried to learned how to write a Python script to send an email with a file attachment. After cross-referencing Python documentation, Stack Overflow questions, and general web searching, I settled with the following code [1] and tested it to be working. import smtplib from email.MIMEMultipart import MIMEMultipart from email.MIMEText import MIMEText from email.MIMEBase import MIMEBase from email import encoders fromaddr = "YOUR EMAIL" toaddr = "EMAIL ADDRESS YOU SEND TO" msg = MIMEMultipart() msg['From'] = fromaddr msg['To'] = toaddr msg['Subject'] =