Search The ForumSearch   RegisterRegister  LoginLogin

MailBee POP3

 AfterLogic Forum : MailBee POP3
Subject Topic: Few lines Post ReplyPost New Topic
Author
Message << Prev Topic | Next Topic >>
rafaellop
Newbie
Newbie


Joined: 13 September 2007
Online Status: Offline
Posts: 26
Posted: 04 October 2007 at 3:17am | IP Logged Quote rafaellop


Hello,

How can I realize the TOP command?

Cheers,
Rafal
Back to Top View rafaellop's Profile Search for other posts by rafaellop
 
rafaellop
Newbie
Newbie


Joined: 13 September 2007
Online Status: Offline
Posts: 26
Posted: 04 October 2007 at 3:35am | IP Logged Quote rafaellop

And one more question. I'd like to use a Message object to load/parse/display EML files located on a drive. I'd like to have only one message object created at the program's initialization and I'd like to just "clear" the message to its default state when I want to load another file or build a message from code. Is there any method that I could use to clear all messsage object properties to a default state like just after the object create call?

Cheers,
Rafal
Back to Top View rafaellop's Profile Search for other posts by rafaellop
 
Alex
AfterLogic Support
AfterLogic Support
Avatar

Joined: 19 November 2003
Online Status: Offline
Posts: 2206
Posted: 04 October 2007 at 8:01am | IP Logged Quote Alex

Quote:
How can I realize the TOP command?

You can use POP3.RetrieveHeaders or similar methods.

Quote:
Is there any method that I could use to clear all messsage object properties to a default state like just after the object create call?

In MailBee POP3, you can re-create an instance (calling CreateObject again). This is the most reliable method. However, if you need to retain the same instance of the object, you can assign its .RawBody to an empty string.

Regards,
Alex
Back to Top View Alex's Profile Search for other posts by Alex
 
rafaellop
Newbie
Newbie


Joined: 13 September 2007
Online Status: Offline
Posts: 26
Posted: 05 October 2007 at 7:54am | IP Logged Quote rafaellop

Thank you or your reply. I've got another question if you don't mind.

It's the Message object related. If I call the GetBodyWithEmbeddedObjects to get the HTML message contents, it returns message text in the system code page (converted), but the HTML output Content-Type declaration is original. If I now pass the HTML text to a browser (e.g. WebBrowser object) the characters in the preview are displayed wrong. I think that the GetBodyWithEmbeddedObjects should return the HTML text without any conversion or, if you want to still convert the characters, it should change the Content-Type declaration in the HTML output. Please let me know your opinion.

Cheers,
Rafal
Back to Top View rafaellop's Profile Search for other posts by rafaellop
 
Alex
AfterLogic Support
AfterLogic Support
Avatar

Joined: 19 November 2003
Online Status: Offline
Posts: 2206
Posted: 05 October 2007 at 8:19am | IP Logged Quote Alex

That's where MessageCensor component comes into play. You can use it to remove META tags with charset information from the body. We use this approach with our WebMail products (you can download WebMail Lite for classic ASP to see how).

Code:

Set objCensor = Server.CreateObject("MC.MessageCensor")
objCensor.AddUnsafeTag "META", 0
text = objMsg.GetCensoredBody(objCensor)


Regards,
Alex
Back to Top View Alex's Profile Search for other posts by Alex
 
rafaellop
Newbie
Newbie


Joined: 13 September 2007
Online Status: Offline
Posts: 26
Posted: 05 October 2007 at 3:33pm | IP Logged Quote rafaellop

I can of course remove the META CHARSET declaration from a HTML file, even without the Message Censor, but the encoding issue is still not fixed.

Most of the browsers use the default encoding option (that a user selects in browser's menu) when a html page doesn't contain meta content type declaration.

For example I can have the iso-8859-2 encoding defined as the default encoding in my browser. Now if try to display a html page, that comes from the Message object, without the meta content type tag, the browser will use the default encoding variable (iso - defined in the browser) rather than the system codepage encoding and the viewed html page will be still unproperly displayed.

That's why I think the html output from the GetBodyWithEmbeddedObjects and GetBodyWithEmbeddedObjectsEx shouldn't be converted to codepage or at least there should be a parameter that will control this conversion.
Back to Top View rafaellop's Profile Search for other posts by rafaellop
 
Alex
AfterLogic Support
AfterLogic Support
Avatar

Joined: 19 November 2003
Online Status: Offline
Posts: 2206
Posted: 07 October 2007 at 7:53am | IP Logged Quote Alex

I still recommend you to download WebMail Lite ASP if you want to learn how to deal with encoding issues.

Specification of charset information in META tag is not recommended. Use Response.Charset instead (and WebMail Lite does this).

Nowdays, it's common practice to output everything as UTF-8:
Code:

' At the top of the page
Response.CharSet = "utf-8"
...
' Before loading message
Msg.Codepage = 65001

' Or, if you get the message from POP3, then
POP3.Codepage = 65001

However, if you still want to preserve the original charset and do not remove META tag, you can do this with MailBee (it's not yet documented but you can specify Message.CodepageMode=3 prior to loading message, or POP3.CodepageMode=3 if you receive the message from POP3 server). No conversion will be made in such case. Of course, if the page also contains another content in another charset (for instance, localized UI elements), it will become unreadable. You'll need v5.5 of MailBee.dll for this (can get it at http://www.afterlogic.com/updates/mailbee.zip

Regards,
Alex
Back to Top View Alex's Profile Search for other posts by Alex
 
rafaellop
Newbie
Newbie


Joined: 13 September 2007
Online Status: Offline
Posts: 26
Posted: 08 October 2007 at 2:43am | IP Logged Quote rafaellop

I have the following code (I use Delphi):

Code:

// working with existing message object
FMessageTesdter2.RawBody := ''; // clear message
FMessageTesdter2.CodepageMode := 3; // no conversion
FMessageTesdter2.ImportFromFile(FMSGSFileNames[msgidx]); // load raw message
result := FMessageTesdter2.GetBodyWithEmbeddedObjects('', '', nil); // get html with extracted attachments


And the resulting string is still converted to the current codepage. I have replaced the MailBlee.dll with the newest 5.5 version and reregistered the DLL. Here is the message source: http://www.spamrebel.com/msg.zip
Back to Top View rafaellop's Profile Search for other posts by rafaellop
 
Andrew
AfterLogic Support
AfterLogic Support


Joined: 28 April 2006
Location: United States
Online Status: Offline
Posts: 1189
Posted: 08 October 2007 at 5:12am | IP Logged Quote Andrew

Please take a look at this screenshot. The windows are:

1. MS Outlook Express displays the message you provided.
2. MS IE 6 displays saved HTML with CodepageMode = 3
3. MS IE 6 displays saved HTML without CodepageMode = 3

As you can see, the contents of the first two windows look identically. We used the source code you provided.

How did you determine that the content is still converted?


Best regards,
Andrew
Back to Top View Andrew's Profile Search for other posts by Andrew
 
rafaellop
Newbie
Newbie


Joined: 13 September 2007
Online Status: Offline
Posts: 26
Posted: 08 October 2007 at 7:58am | IP Logged Quote rafaellop

Quote:

How did you determine that the content is still converted?


I did this simply by looking into the output HTML code and compare it to the RAW message source. In the RAW the iso characters are encoded using the iso. In the HTML output from the GetBodyWithEmbeddedObjects is in Windows CP encoding.

Please try to change the MSIE default encoding -> Right click on the HTML page in MSIE -> Encoding menu -> check "Automatic" and also check "Eastern Europe (ISO)".

BTW. How could I determine in runtime mode that the DLL is 5.5 ? Maybe there's a copy somewhere that is older?
Back to Top View rafaellop's Profile Search for other posts by rafaellop
 
Andrew
AfterLogic Support
AfterLogic Support


Joined: 28 April 2006
Location: United States
Online Status: Offline
Posts: 1189
Posted: 08 October 2007 at 8:15am | IP Logged Quote Andrew

To determine which version is used, enable logging, try to connect to a mail server and check the first line of the log file. The following sample tries to connect to not existing mail server (it doesn't matter whether the mail server exists or not) and creates the log file (VB6 syntax):

Code:
Dim Mailer
Set Mailer = CreateObject("MailBee.POP3")

Mailer.EnableLogging = True
Mailer.LogFilePath = "C:\my_log.txt"
Mailer.ClearLog

Mailer.LicenseKey = "put your license key here"

Mailer.Connect("mailserver.com", ,"MyName", "MyPassword")


Please make sure the application has permission to write into the specified location.


Best regards,
Andrew
Back to Top View Andrew's Profile Search for other posts by Andrew
 

If you wish to post a reply to this topic you must first login
If you are not already registered you must first register

  Post ReplyPost New Topic
Printable version Printable version

Forum Jump

Powered by Web Wiz Forums version 7.9
Copyright ©2001-2004 Web Wiz Guide