Solved

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

Posted on 2008-10-23
11
1,024 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
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 
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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Error viewing ASP page 12 162
ASP CDO - Limiting Connections 2 50
Query still returning duplicates 5 26
SharePoint Explorer Folder Access 4 35
If you don't have the right permissions set for your WordPress location in IIS, you won't be able to perform automatic updates. Here's how to fix the problem.
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…
In this video I am going to show you how to back up and restore Office 365 mailboxes using CodeTwo Backup for Office 365. Learn more about the tool used in this video here: http://www.codetwo.com/backup-for-office-365/ (http://www.codetwo.com/ba…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

816 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

10 Experts available now in Live!

Get 1:1 Help Now