Login  
Search All Forums
Dart Home | PowerTCP Mail for .NET | Custom Development Reply | PowerTCP Mail for .NET Topics | Forums   
AuthorForum: PowerTCP Mail for .NET
Topic: Message Part Stream Content Type
jaltrichter

From: Newark, DE USA
Posts: 4
Member Since: 07/08/08
posted July 8, 2008 5:17 PM

I have a Windows Service application needs uses the POP object to read messages from a mailbox and extract both the Text and Html body parts.

I have used your example code to iterate through the Message Part collection and find the HTML content, but in order to do this it is necessary to compare they Content Type string to the IETF text literals. Example code follows:

For Each Part In Msg.Parts.Simple
 If Part.ContentEncoding = ContentEncoding.QuotedPrintable Then
   If Part.ContentType = "text/html" Then …

Is there a way to perform this type of comparison using the Content Type Enumeration?

Is there a reason why the Message Part Stream. Content Type does not use that enumeration by default?
Jason Farrar (Admin)

From: Oneida, NY USA
Posts: 223
Member Since: 07/24/07

Extra Support Options
Custom Application Development

posted July 9, 2008 5:31 PM

There isn't a way to use the enumerations in this manner. I believe it is because using a stream afforded more flexibility in the event that the RFC's were ever expanded upon.
jaltrichter

From: Newark, DE USA
Posts: 4
Member Since: 07/08/08
posted July 10, 2008 9:44 AM

Thanks for the follow-up Jason. I didn't quite understand the comment about the "stream' afforded more flexibility. I guess that you meant storing content type as a string accomodates future revisions to RFC 1521.

My point was that when you look at the contstructor for the Message Part Stream it uses the ContentType enumeration.

Initializes a new MessagePartStream with the provided parameters.

[Visual Basic]
Public Sub New( _
  ByVal text As String, _
  ByVal type As ContentType, _
  ByVal encoding As ContentEncoding, _
  ByVal charset As String _
)

So the ContentType enumeration clearly converts to a RFC 1521 string to send a message. 

Is there some way to use the ContentType enumeration to match RFC 1521 values when examing a message part? 

Currently ContentType.toString does not produce an RFC 1521 format string. Is there some method that I am missing to perform this comparison?
Jason Farrar (Admin)

From: Oneida, NY USA
Posts: 223
Member Since: 07/24/07

Extra Support Options
Custom Application Development

posted July 10, 2008 3:25 PM

I understand your confusion. To be honest I don't know why the design decision was made to have an enumerable type included. The .NET framework that we compile against does not have support for String type Enumerations. The ToString method will not work because the Enumeration names are not the exact IETF literals.

So to answer your question, there is no way to use the enumerator in this fashion.
wilpeck

From: Olathe, KS USA
Posts: 4
Member Since: 07/23/08
posted July 23, 2008 2:17 PM

There is a class in the System.Net.Mime namespace called MediaTypeNames. I think it will give you some of what you are looking for when it comes to common content types like image/jpeg, etc... I ended up using this on the various CodingStream types ContentType property. I'm not sure if the Part class ContentType property is a string, but if this is the MediaTypeNames property may give you some of what you're looking for.
Reply | PowerTCP Mail for .NET Topics | Forums   
This site is powered by PowerTCP WebServer Tool PowerTCP WebServer for ActiveX