Search The ForumSearch   RegisterRegister  LoginLogin

MailBee.NET Objects

 AfterLogic Forum : MailBee.NET Objects
Subject Topic: how to print only first 20 char of e-mail Post ReplyPost New Topic
Author
Message << Prev Topic | Next Topic >>
rre
Newbie
Newbie
Avatar

Joined: 04 September 2009
Location: Italy
Online Status: Offline
Posts: 7
Posted: 08 September 2009 at 6:29am | IP Logged Quote rre

Hello,

I wuould like to print only the first 200 characters of the email I receive.

So I make the plain txt message, cut it, transform on html and save it. And at last display with my browser.

I tryed this code:

8<-------------------------------------------
msg.Parser.WorkingFolder = tmpPath & TmpDir

sw = New StreamWriter(tmpPath & TmpDir & "\Index.html", False)

msg = pop.DownloadEntireMessage(pop.GetMessageIndexFromUid(Udi))

If Len(msg.BodyPlainText) > 200 Then
   msg.BodyPlainText = Mid(msg.BodyPlainText, 1, 200))
   msg.BodyPlainText = msg.BodyPlainText & "<b>[... CUTTED ...]</b>"
End If

msg.Parser.PlainToHtmlMode = PlainToHtmlAutoConvert.IfNoHtml
msg.Parser.PlainToHtmlOptions = PlainToHtmlConvertOptions.UriToLink

msg.Parser.Apply()

sw.Write(msg.GetHtmlAndSaveRelatedFiles(Nothing, VirtualMappingType.NonWeb, MessageFolderBehavior.CreateOnly))

[...]
'display the file with web browser
8<-------------------------------------------

the problem is that the msg.GetHtmlAndSaveRelatedFiles writes the complete message from mailServer, not the cutted in memory.

someone can help me?

thanks

Rre
Back to Top View rre's Profile Search for other posts by rre
 
Igor
AfterLogic Support
AfterLogic Support


Joined: 24 June 2008
Location: United States
Online Status: Offline
Posts: 6094
Posted: 08 September 2009 at 7:16am | IP Logged Quote Igor

Not sure if I got the point of this clearly enough. Looks like you'd like to create HTML content based on trimmed plaintext body. But in this situation, using GetHtmlAndSaveRelatedFiles method seems to be pointless as any links to related files will be lost, and any HTML tags too. For your scenario, I'd suggest using BodyHtmlText property of MailMessage object.

--
Regards,
Igor, AfterLogic Support
Back to Top View Igor's Profile Search for other posts by Igor
 
rre
Newbie
Newbie
Avatar

Joined: 04 September 2009
Location: Italy
Online Status: Offline
Posts: 7
Posted: 08 September 2009 at 8:35am | IP Logged Quote rre

Sorry, I will try to better explain.

I have to print the e-mail I receive only for the first X characters (with X from 0 to watever). Also is acceptable a X number of rows.

If on this first range there is a table or a picture or stay insite the full e-mail I have to print it.

So I think to apply what you say on Tutorials and translate on html.

But obviously cutting the first 200 char on html brutally wil not works.

And if first I translate to plain text will not works too.

I'm looking for an idea of implementation.

Thanks

Rre
Back to Top View rre's Profile Search for other posts by rre
 
Igor
AfterLogic Support
AfterLogic Support


Joined: 24 June 2008
Location: United States
Online Status: Offline
Posts: 6094
Posted: 09 September 2009 at 12:19am | IP Logged Quote Igor

I don't think there's an easy solution for the task you have at hands. If you'd like to trim HTML body, you'll need to ensure that HTML code remains correct after this operation and all the tags are closed properly, with all possible situations foreseen. This would probably require manipulating Document Object Model of HTML, so you can calculate the total length of textual content in HTML output and omit all the texts, inline images and such after the boundary is reached. You can implement this yourself, and MailBee.Html component may be helpful in this regard. Alternatively, you can engage our Professional Services to do this for you.

--
Regards,
Igor, AfterLogic Support
Back to Top View Igor's Profile Search for other posts by Igor
 
rre
Newbie
Newbie
Avatar

Joined: 04 September 2009
Location: Italy
Online Status: Offline
Posts: 7
Posted: 09 September 2009 at 12:44am | IP Logged Quote rre

Yes, I understand.

Thanks

Rre
Back to Top View rre's Profile Search for other posts by rre
 
rre
Newbie
Newbie
Avatar

Joined: 04 September 2009
Location: Italy
Online Status: Offline
Posts: 7
Posted: 06 October 2009 at 3:02pm | IP Logged Quote rre

Ok, I wrote a solution! javascript:AddSmileyIcon('')

The solution is to parse the message, count inside all nodes the char of text and, arrived to 'max char number', leave the text void.

Probably you can cut all the nodes, but I think a little more complex close the other just opened.

I done this with hmtlAgility pack. But for sure you can do that with the MailBee.Html.

If somebody like I can send the class on VB.NET that make this.

ciao

RRE
Back to Top View rre's Profile Search for other posts by rre
 

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