Solved

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

Posted on 2008-10-23
11
1,019 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
 
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
Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

 
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

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

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 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/…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

757 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now