Login  
Search All Forums
Dart Home | PowerTCP Mail for ActiveX | Custom Development Reply | PowerTCP Mail for ActiveX Topics | Forums   
AuthorForum: PowerTCP Mail for ActiveX
Topic: Saving an Attachment
ubigloser

From: Nowhere, UT USA
Posts: 8
Member Since: 04/08/04
posted April 12, 2004 7:21 PM

I'm trying to figure out how to save an attachment, but am a little unclear as to how... Here's what I'd like to do (without saving ALL attachments):

Message.Load strFilename
For i = 1 to Message.PartList.Count
 Set objPart = Message.PartList.Item(x)
 If i = 1 Then
  objPart.SaveToDisk <-- how???
 End If
Next i

Is it possible to save just one of the attachments without saving all of them? (Yes, I am aware of the .AttachmentDirectory property). I'd like to maintain control over this because I am providing a web-based solution to my users and I don't want to have to keep track of all of the attachments - only when the user clicks on the attachment to download, that is when I want to save it to a temporary location.

Thanks.
Tony Priest



From: Utica, NY USA
Posts: 8466
Member Since: 04/11/00
posted April 12, 2004 7:27 PM

First set Attachment directory to false to stop automatic saving. Then use Part.Data to access the string or ByteArray data in the file (see the Help for details)

Once you have the data just use some sort of File I/O object to save it. You can use DartStream if you want:

Dim stream as new DartStream
stream.Filemode = createAlways
stream.Filename = Part.File
stream.Write Part.Data
Set stream = Nothing
ubigloser

From: Nowhere, UT USA
Posts: 8
Member Since: 04/08/04
posted April 12, 2004 7:45 PM

Oh, so the .Data method will automatically decode the data? I guess I thought it would come through as the encoded data.

Thanks, I'll give it a try.
ubigloser

From: Nowhere, UT USA
Posts: 8
Member Since: 04/08/04
posted April 12, 2004 11:52 PM

Seems to work nicely. I might add that it is important to set the .AttachmentDirectory = "" BEFORE iterating through the parts - for some reason, it sticks misc. characters in the filename if you don't, such as (98) and ./

I'm not sure why. At any rate, it all works dandy now. Thanks for your prompt help!
Reply | PowerTCP Mail for ActiveX Topics | Forums   
This site is powered by PowerTCP WebServer Tool PowerTCP WebServer for ActiveX