EldoS | Feel safer!

Software components for data protection, secure storage and transfer

Save TElMessage object to file keeping its original data i

Also by EldoS: Callback File System
Create virtual file systems and disks, expose and manage remote data as if they were files on the local disk.
#32431
Posted: 03/03/2015 03:10:57
by Ako Dpeps (Basic support level)
Joined: 02/25/2015
Posts: 13

How can I save a TElMessage object to file keeping its original data including digital signatures ?

The problem is that the signature is not valid any more when opening the exported .eml file in Outlook:

Code

TElMessage message2;
int options =SBMIME.__Global.mpoLoadData|SBMIME.__Global.mpoStoreStream;
client.ReceiveMessage(messageId.Index, "", "",options,
                        true, false, false, out message2);
String filename = @"C:\temp\" + message2.MessageID + ".eml";
Stream stream = new FileStream(filename, FileMode.Create);
message2.AssembleMessage(stream);


I know there is another ReceiveMessage overload with a byte[] parameter. But I want to use TElMessage object as I don't want to load the an exported email from disk to create a TElMessage object.
#32432
Posted: 03/03/2015 03:19:42
by Eugene Mayevski (EldoS Corp.)

Basically, you can't.

Your code is re-assembling the message, i.e. creating a new message. Obviously you can't apply an existing digital signature to the new message.

The right approach is to keep a copy of the original message data somewhere and save it if needed.


Sincerely yours
Eugene Mayevski
#32434
Posted: 03/03/2015 03:43:34
by Ako Dpeps (Basic support level)
Joined: 02/25/2015
Posts: 13

But how can get the original message ? Do I have to use the ReceiveMessage overload with "Stream" ? And then I would have to read it again from disk to get a TElMessage object ?
#32435
Posted: 03/03/2015 04:04:26
by Eugene Mayevski (EldoS Corp.)

I assume that you are talking about TElPOP3Client.

ReceiveMessage has three overloads -- the one that fires OnMessageLine event for each line of the message, the one that saves the data to stream (and you can use MemoryStream for this) and the one that you used.

Obviously you can use one of the alternatives to store the data somewhere and load the message from there.

Remember that when you read the data from the stream, you need to first reset stream position to 0.


Sincerely yours
Eugene Mayevski

Reply

Statistics

Topic viewed 394 times

Number of guests: 1, registered members: 0, in total hidden: 0




|

Back to top

As of July 15, 2016 EldoS Corporation will operate as a division of /n software inc. For more information, please read the announcement.

Got it!