Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

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

Posted on 2008-10-23
11
Medium Priority
?
1,050 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
10 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
Configuration Guide and Best Practices

Read the guide to learn how to orchestrate Data ONTAP, create application-consistent backups and enable fast recovery from NetApp storage snapshots. Version 9.5 also contains performance and scalability enhancements to meet the needs of the largest enterprise environments.

 
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 1600 total points
ID: 22815040
Must be a gmail design flaw.

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

Featured Post

Nothing ever in the clear!

This technical paper will help you implement VMware’s VM encryption as well as implement Veeam encryption which together will achieve the nothing ever in the clear goal. If a bad guy steals VMs, backups or traffic they get nothing.

Question has a verified solution.

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

I was asked about the differences between classic ASP and ASP.NET, so let me put them down here, for reference: Let's make the introductions... Classic ASP was launched by Microsoft in 1998 and dynamically generate web pages upon user interact…
Prologue It is often required to host multiple websites on a single instance of IIS, mostly in development environments instead of on production servers. I am sure it is not much a preferred solution on production servers but this is at least a pos…
this video summaries big data hadoop online training demo (http://onlineitguru.com/big-data-hadoop-online-training-placement.html) , and covers basics in big data hadoop .
Screencast - Getting to Know the Pipeline
Suggested Courses
Course of the Month8 days, 10 hours left to enroll

876 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