Solved

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

Posted on 2008-10-23
11
1,038 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Business Impact of IT Communications

What are the business impacts of how well businesses communicate during an IT incident? Targeting, speed, and transparency all matter. Find out more in this infographic.

 
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

Ransomware: The New Cyber Threat & How to Stop It

This infographic explains ransomware, type of malware that blocks access to your files or your systems and holds them hostage until a ransom is paid. It also examines the different types of ransomware and explains what you can do to thwart this sinister online threat.  

Question has a verified solution.

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

First of all, clustering IIS is something you should rarely consider doing. In almost all cases, Microsoft Network Load Balancing (NLB) (http://technet.microsoft.com/en-us/library/cc758834(WS.10).aspx) is a much better solution when you need to p…
Have you ever needed to get an ASP script to wait for a while? I have, just to let something else happen. Or in my case, to allow other stuff to happen while I was murdering my MySQL database with an update. The Original Issue This was written…
Finding and deleting duplicate (picture) files can be a time consuming task. My wife and I, our three kids and their families all share one dilemma: Managing our pictures. Between desktops, laptops, phones, tablets, and cameras; over the last decade…

710 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