473,414 Members | 1,675 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,414 software developers and data experts.

Decoding MIME encoded email subject

Greetings all- I am trying to extract subject headers from emails that
have been saved as text files. The subject headers are in MIME UTF-8
format, and so they appear like this:

subject:
=?utf-8?B?QVVUTyBQRU9QTEUgLS0gTWFuaGVpbeKAmXMgSmVmZiBCdW 5jaCBpbiBIaWdoYmVhbXM7IExlZ2VuZGFyeSBSZWQgTWNDb21i czsgV2hv4oCZcyBTaGlmdGluZyBHZWFycz87IE1vcmU=?=

What class can I use to decode the subject text?

Dec 21 '06 #1
3 10920

That's not MIME format. MIME provides separation of message parts and
embedding of messages within other messages.

That's probably base64 or uuencode or something like that, not sure
exactly. The MIME header should have an encoding line which says what
encoding is used for the rest of the message. Most commonly MIME
messages are encoded with Quoted-Printable for text and Base64 for
binary. QP looks pretty much just like regular text with a lot of
extra = signs.

If this isn't enough info, post more of the MIME message.

Sam

------------------------------------------------------------
We're hiring! B-Line Medical is seeking Mid/Sr. .NET
Developers for exciting positions in medical product
development in MD/DC. Work with a variety of technologies
in a relaxed team environment. See ads on Dice.com.
On Thu, 21 Dec 2006 13:05:03 -0600, b. dougherty
<au****************@austin.rr.comwrote:
>Greetings all- I am trying to extract subject headers from emails that
have been saved as text files. The subject headers are in MIME UTF-8
format, and so they appear like this:

subject:
=?utf-8?B?QVVUTyBQRU9QTEUgLS0gTWFuaGVpbeKAmXMgSmVmZiBCdW 5jaCBpbiBIaWdoYmVhbXM7IExlZ2VuZGFyeSBSZWQgTWNDb21i czsgV2hv4oCZcyBTaGlmdGluZyBHZWFycz87IE1vcmU=?=

What class can I use to decode the subject text?
Dec 21 '06 #2
Sorry, it appears to be a message header extension, formatted as
described in section 4.1 of this:

http://tools.ietf.org/html/rfc2047

Any idea what class can decode this? Here's a larger snippet of the
mail:

--------------------------------------------------------------------

Content-Type: message/rfc822

Received: from SERVER ([x.x.x.x]) by x.com with Microsoft
SMTPSVC(6.0.3790.1830);
Wed, 13 Dec 2006 22:12:17 -0800
mime-version: 1.0
from: "User" <ma****@x.com>
to: y@y.com
date: 13 Dec 2006 22:12:17 -0800
subject:
=?utf-8?B?QVVUTyBQRU9QTEUgLS0gTWFuaGVpbeKAmXMgSmVmZiBCdW 5jaCBpbiBIaWdoYmVhbXM7IExlZ2VuZGFyeSBSZWQgTWNDb21i czsgV2hv4oCZcyBTaGlmdGluZyBHZWFycz87IE1vcmU=?=
content-type: multipart/mixed;
boundary=--boundary_54358_dc8ddb80-9498-4b90-8e3e-3d2c411a5160

--------------------------------------------------------------------

On Thu, 21 Dec 2006 17:35:05 -0500, Samuel R. Neff
<sa********@nomail.comwrote:
>
That's not MIME format. MIME provides separation of message parts and
embedding of messages within other messages.

That's probably base64 or uuencode or something like that, not sure
exactly. The MIME header should have an encoding line which says what
encoding is used for the rest of the message. Most commonly MIME
messages are encoded with Quoted-Printable for text and Base64 for
binary. QP looks pretty much just like regular text with a lot of
extra = signs.

If this isn't enough info, post more of the MIME message.

Sam

------------------------------------------------------------
We're hiring! B-Line Medical is seeking Mid/Sr. .NET
Developers for exciting positions in medical product
development in MD/DC. Work with a variety of technologies
in a relaxed team environment. See ads on Dice.com.
On Thu, 21 Dec 2006 13:05:03 -0600, b. dougherty
<au****************@austin.rr.comwrote:
>>Greetings all- I am trying to extract subject headers from emails that
have been saved as text files. The subject headers are in MIME UTF-8
format, and so they appear like this:

subject:
=?utf-8?B?QVVUTyBQRU9QTEUgLS0gTWFuaGVpbeKAmXMgSmVmZiBCdW 5jaCBpbiBIaWdoYmVhbXM7IExlZ2VuZGFyeSBSZWQgTWNDb21i czsgV2hv4oCZcyBTaGlmdGluZyBHZWFycz87IE1vcmU=?=

What class can I use to decode the subject text?
Dec 21 '06 #3
b. dougherty wrote:
Greetings all- I am trying to extract subject headers from emails that
have been saved as text files. The subject headers are in MIME UTF-8
format, and so they appear like this:

subject:
=?utf-8?B?QVVUTyBQRU9QTEUgLS0gTWFuaGVpbeKAmXMgSmVmZiBCdW 5jaCBpbiBIaWdoYmVhbXM7IExlZ2VuZGFyeSBSZWQgTWNDb21i czsgV2hv4oCZcyBTaGlmdGluZyBHZWFycz87IE1vcmU=?=

What class can I use to decode the subject text?
Try this:

public static string Decode(string s)
{
MatchCollection rr = Regex.Matches(s,
@"(?:=\?)([^\?]+)(?:\?B\?)([^\?]*)(?:\?=)");
string charset = rr[0].Groups[1].Value;
string data = rr[0].Groups[2].Value;
byte[] b = Convert.FromBase64String(data);
string res = Encoding.GetEncoding(charset).GetString(b);
return res;
}

Arne

Dec 24 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Thomas Williams | last post by:
Hello everyone, my name is Tom W. And, I am new to the list, and have been using Python for about a year now. Anyway, I got a question! I am trying to decode MIME (base64) email from a POP3...
1
by: Thomas Williams | last post by:
Thanks, I tried it and it stop at: f = file("mail.txt") with the error message. TypeError: 'str' object is not callable Tom Williams
2
by: David Stockwell | last post by:
snippet payload = {} try: message = email.message_from_string(message) messageHeader = dict(message._headers) addressFrom = messageHeader addressReply = messageHeader.get("Reply-To")...
2
by: asnowfall | last post by:
I am trying to build System.Mail.MailMessage object out of mime encoded SMTP data. I have following questions Byte byteMailData; //mime encoded STMP data for "email with attachment" 1)...
3
by: Laangen_LU | last post by:
Dear Group, my first post to this group, so if I'm on the wrong group, my apologies. I'm trying to send out an email in Chinese lanuage using the mail() function in PHP. Subject and...
2
by: gweasel | last post by:
I've got the following code on the "OnClick" event for a command button on a form. ______________________________________ Private Sub EmailNotify_Click() DoCmd.SendObject acSendNoObject, , ,...
4
by: Ciuin | last post by:
Hi all, I need to mail() emails with user input that does contain non-ascii (umlauts, accents) and non-latin (cyrillic) characters in the "Subject:" and "From:" headers. I understand that they...
1
by: praveen2gupta | last post by:
I am working on email server. It is running fine on all English mails. Recently I have converted it to multi language. All laguage are good with in server mail send and received. My Problem is...
7
by: Ron Garret | last post by:
I'm writing a little HTTP server and need to parse request content that is mime-encoded. All the MIME routines in the Python standard library seem to have been subsumed into the email package,...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.