473,721 Members | 2,216 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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?QVVUTyBQRU9 QTEUgLS0gTWFuaG VpbeKAmXMgSmVmZ iBCdW5jaCBpbiBI aWdoYmVhbXM7IEx lZ2VuZGFyeSBSZW QgTWNDb21iczsgV 2hv4oCZcyBTaGlm dGluZyBHZWFycz8 7IE1vcmU=?=

What class can I use to decode the subject text?

Dec 21 '06 #1
3 11010

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?QVVUTyBQRU9 QTEUgLS0gTWFuaG VpbeKAmXMgSmVmZ iBCdW5jaCBpbiBI aWdoYmVhbXM7IEx lZ2VuZGFyeSBSZW QgTWNDb21iczsgV 2hv4oCZcyBTaGlm dGluZyBHZWFycz8 7IE1vcmU=?=

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.379 0.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?QVVUTyBQRU9 QTEUgLS0gTWFuaG VpbeKAmXMgSmVmZ iBCdW5jaCBpbiBI aWdoYmVhbXM7IEx lZ2VuZGFyeSBSZW QgTWNDb21iczsgV 2hv4oCZcyBTaGlm dGluZyBHZWFycz8 7IE1vcmU=?=
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********@nom ail.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?QVVUTyBQRU9 QTEUgLS0gTWFuaG VpbeKAmXMgSmVmZ iBCdW5jaCBpbiBI aWdoYmVhbXM7IEx lZ2VuZGFyeSBSZW QgTWNDb21iczsgV 2hv4oCZcyBTaGlm dGluZyBHZWFycz8 7IE1vcmU=?=

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?QVVUTyBQRU9 QTEUgLS0gTWFuaG VpbeKAmXMgSmVmZ iBCdW5jaCBpbiBI aWdoYmVhbXM7IEx lZ2VuZGFyeSBSZW QgTWNDb21iczsgV 2hv4oCZcyBTaGlm dGluZyBHZWFycz8 7IE1vcmU=?=

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.FromBas e64String(data) ;
string res = Encoding.GetEnc oding(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
3470
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 server, but all I get is a corrupt file. I know that it good to begin with because I check it with another email client. This is what I am doing!
1
3735
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
2836
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") messageId = messageHeader.get("Message-ID")
2
3098
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) MailMessage.Body = Convert(byteMailData); If I do the above, will MailMessage object extract the Message BODY, Message HEADER and Attachments automatically.
3
8744
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 mailbody are stored as Unicode entities (eg. 註)
2
1603
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, , , "user@company.com", CCFIELD, BCCFIELD, , BODY_HERE, False End Sub ______________________________________
4
17600
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 are typically encoded in UTF8 like this: =?UTF-8?B?w5Z0emkg0J/RgNC40LLQtdGC?= but I cannot find a PHP function to encode the input string in this
1
1669
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 the mails received from gmail in other than english. I am not able to display the subject of the mail received .The body part is ok. charset utf-8 used to display subject and body. the characters stored in the database is Example ...
7
2938
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, which makes this operation a little awkward. It seems I have to do the following: 1. Extract the content-length header from the HTTP request and use that to read the payload. 2. Stick some artificial-looking headers onto the beginning of this...
0
8840
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8730
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9064
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8007
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6669
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5981
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4484
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4753
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2130
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.