Messages sent using CDO arriving as text

D

Danila

Hi.
I need to write an application that takes messages from exchange mailfolder,
saves them to xml file,
then loads the messages from file into another exchange folder and finally
sends these messages to receipients.

I use adodb to read the messages into recordset and then for each record, Im
writing the message stream
(rec.Fields(-1)) into xml file.
Then I open empty record in target URL and update message stream using the
same idea

When I open the message in target folder using outlook it seems identical to
original message.

After that, I once again read the message stream and load it into
CDO.IDataSource object,
and send it to receipients.

When message arrives it looks like this:
â€X-MimeOLE: Produced By Microsoft Exchange V6.5
Received: by _________.vnc.com id <01C67813.5D3D5490@________.vnc.com>;
Mon, 15 May 2006 13:33:19 +0200
MIME-Version: 1.0
Content-Type: multipart/related;
type="text/html";
boundary="----_=_NextPart_001_01C67813.5D3D5490"
Content-class: urn:content-classes:message
Subject: black red 10
Message-ID: <[email protected]>
Date: Mon, 15 May 2006 13:50:01 +0200
Content-Transfer-Encoding: 7bit
X-MS-Has-Attach: yes
X-Mailer: Microsoft CDO for Windows 2000
X-MS-TNEF-Correlator:
Thread-Topic: black red 10
Thread-Index: AcZ4E10CZK3iJLQRRxSq4hpXE0DrJQ==
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.2663
From: "Daniel Sokolov" <daniels@________.co.il>
Importance: normal
To: "Daniel Sokolov" <daniels@_______.co.il>
Priority: normal

This is a multi-part message in MIME format.

------_=_NextPart_001_01C67813.5D3D5490
Content-Type: text/html;
charset="US-ASCII"
Content-Transfer-Encoding: quoted-printable

<html xmlns:v=3D"urn:schemas-microsoft-com:vml" =
xmlns:eek:=3D"urn:schemas-microsoft-com:eek:ffice:eek:ffice" =
xmlns:w=3D"urn:schemas-microsoft-com:eek:ffice:word" =
xmlns:st1=3D"urn:schemas-microsoft-com:eek:ffice:smarttags" =
xmlns=3D"http://www.w3.org/TR/REC-html40"
.....................

I include the functions I use to accomplish the above:

'Puts Updates empty message in target URL
Private Sub SetBinaryData(ByVal xmlnodeMsg As XmlNode, ByRef recMsg As
ADODB.Record)
Dim xmlData As XmlCDataSection =
CType(xmlnodeMsg.SelectSingleNode("BinaryData").FirstChild, XmlCDataSection)
Dim dataStream As ADODB.Stream
Dim str As String
Try
dataStream = recMsg.Fields(-1).Value
str = xmlData.Data
dataStream.WriteText(str)
recMsg.Fields(-1).Value = dataStream
System.Diagnostics.EventLog.WriteEntry(Me.GetType().ToString(),
"SetBinaryData:BinaryData Successfully Updated")
Catch ex As Exception
System.Diagnostics.EventLog.WriteEntry(Me.GetType().ToString(),
ex.Message)
End Try
End Sub


Private Sub SendMail(ByVal recMsg As ADODB.Record, ByVal username As
String, ByVal password As String, ByVal logger As Logger)
Dim streamMsg As ADODB.Stream
Dim iMsg As New CDO.Message
Dim iDsrc As CDO.IDataSource
Dim iConf As CDO.Configuration
Try
iConf = New CDO.Configuration
iConf.Fields( _

"http://schemas.microsoft.com/cdo/configuration/sendusing" _
).Value = CDO.CdoSendUsing.cdoSendUsingPickup
streamMsg = New ADODB.Stream
streamMsg.Open(recMsg, ADODB.ConnectModeEnum.adModeRead _
, ADODB.StreamOpenOptionsEnum.adOpenStreamFromRecord _
, username, password)

iMsg.Configuration = iConf
iDsrc = iMsg
iDsrc.OpenObject(streamMsg, CDO.CdoInterfaces.cdoIStream)
iMsg.AutoGenerateTextBody = False
iMsg.MimeFormatted = True

iMsg.BodyPart.ContentClass = "urn:content-classes:message"
iMsg.BodyPart.ContentMediaType =
CDO.CdoContentTypeValues.cdoMultipartRelated
iMsg.Send()


Catch ex As Exception
logger.WriteException(ex, Me.GetType().Assembly)
End Try

End Sub

Please, Help
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top