Solved

CDO UTF-8 email subject being cut off after 32 characters

Posted on 2008-10-23
11
1,031 Views
Last Modified: 2012-05-05
Hi there

I have a email function that generates messages. The problem is when the variable mysubject is over 32 characters long it gets cut off. I am using different languages so the email needs to be sent in UTF-8.

The message header looks like this

Thread-Topic: =?utf-8?Q?Web_=E2=80=93_New_Case_for_origin_web_de?=
      =?utf-8?Q?sign_LTD/123456?=
From: <admin@xxxxxxxx.co.uk>
To: <xxxx@xxxxxxxx.co.uk>
MAILER-TRACE:0
      =?utf-8?Q?sign_LTD/123456?=

You can see that MAILER-TRACE:0 has the final part, so its cutting it off

If the message is sent without UTF8 the subjects are fine.

Please help

 
function sendmail(myfromemail,mytoemail,mysubject,mymessage)
	
  sch = "http://schemas.microsoft.com/cdo/configuration/" 
 
    Set cdoConfig = CreateObject("CDO.Configuration") 
 
	 With cdoConfig.Fields 
        .Item(sch & "sendusing") = 2 ' cdoSendUsingPort 
        .Item(sch & "smtpserver") = "mail.mymailserver.co.uk"
        .update 
    End With 
 
    Set cdoMessage = CreateObject("CDO.Message") 
 
    With cdoMessage 
        Set .Configuration = cdoConfig 
		
        .From = myfromemail
        .To = mytoemail
        .Subject = mysubject
	.BodyPart.ContentMediaType = "text/plain"
	.BodyPart.Charset = "utf-8"
        .HTMLBody = mymessage 
        .Send 
    End With 
 
    Set cdoMessage = Nothing 
    Set cdoConfig = Nothing
 
end function

Open in new window

0
Comment
Question by:Dark_Entity
  • 7
  • 3
11 Comments
 
LVL 29

Expert Comment

by:Badotz
ID: 22807247
I don't know, but perhaps it is a limitation of the CDO object?

It is, after all, the SUBJECT of your message, not the message itself.
0
 

Author Comment

by:Dark_Entity
ID: 22814256
Its a tricky one because when I receive the email from a email account on my server the subject line is fine and uncut, however when it is sent to say a gmail account it gets cut off. Probably the mail server isn't liking the format of the subject header. If someone could test it on a windows 2003 server and send to a gmail account to replicate the problem, least I would know it is a general problem and not my server config.

Also if someone could recommend a free alternative asp mail component that might be able to handle UFT-8 better I can try that instead. Can't believe no one else has come across this issue before.
0
 
LVL 29

Expert Comment

by:Badotz
ID: 22814451
I sent a message to gmail with thie subject of

=?utf-8?Q?Web_=E2=80=93_New_Case_for_origin_web_de?==?utf-8?Q?sign_LTD/123456?=

and when the message arrived, it had been altered to this:

Web  New Case for origin web design LTD/123456

It looks like it's You vs. Google, and the outcome is pretty predictable.
0
U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

 
LVL 29

Expert Comment

by:Badotz
ID: 22814461
@#$% RTF editor - another attempt:

// I sent a message to gmail with thie subject of
 
// =?utf-8?Q?Web_=E2=80=93_New_Case_for_origin_web_de?==?utf-8?Q?sign_LTD/123456?=
 
// and when the message arrived, it had been altered to this:
 
// Web  New Case for origin web design LTD/123456
 
// It looks like it's You vs. Google, and the outcome is pretty predictable.

Open in new window

0
 
LVL 29

Expert Comment

by:Badotz
ID: 22814481
Well, I can't even show you the results. @#$% text editor strips out what we want to see.

The



character is a long dash, viewed in my email client.
0
 
LVL 29

Expert Comment

by:Badotz
ID: 22814492
btw: I sent an email to gmail with the subject of:

This is a really long subject line, only text and punctuation, possibly some numbers 0123456789 for good measure.

and it did not chop it up.
0
 

Author Comment

by:Dark_Entity
ID: 22814780
I don't think sending that subject heading to google will replicate the problem. As you can see below the header has returned it to another line, where as you sent it in one line. This doesn't just happen with google, also exchange server. Ideally I need to stop the subject line being encoded with UTF-8 with only the body of the message being encode

Thread-Topic: =?utf-8?Q?Web_=E2=80=93_New_Case_for_origin_web_de?=
      =?utf-8?Q?sign_LTD/123456?=
0
 
LVL 29

Expert Comment

by:Badotz
ID: 22814846
>>I don't think sending that subject heading to google will replicate the problem.

It sure changed the subject of the subject.

>>As you can see below the header has returned it to another line, where as you sent it in one line.

I have no idea what you mean. How has it been split into two lines?

>>If someone could test it on a windows 2003 server and send to a gmail account to replicate the problem, least I would know it is a general problem and not my server config.

Sorry, only have WinXP Pro SP3.
0
 

Author Comment

by:Dark_Entity
ID: 22814985
It will change the subject by stripping out the code between the question marks as you said but it didn't chop off any of it because it was sent in one line with your email program, where as if you look at my last post above the Thread-Topic it's split onto 2 lines. I  have read somewhere that UTF-8 encodes in blocks probably 32 character long or something like that, so when the email is generated it returns the line after 32 characters and when say google receives the message it ignores the second line as if it doesn't exist.
0
 
LVL 29

Accepted Solution

by:
Badotz earned 400 total points
ID: 22815040
Must be a gmail design flaw.

Anyhow, nothing more I can do for you, sorry.
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This demonstration started out as a follow up to some recently posted questions on the subject of logging in: http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28634665.html and http://www.experts-exchange.com/Programming/…
When it comes to showing a 404 error page to your visitors, you do not want that generic page to show, and you especially do not want your hosting provider’s ad error page to show either. In this article, I will show you how to enable the custom 40…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

820 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question