diff options
author | Vincent Richard <[email protected]> | 2006-10-14 08:31:25 +0000 |
---|---|---|
committer | Vincent Richard <[email protected]> | 2006-10-14 08:31:25 +0000 |
commit | 6139afdbf8a0fced0cb31f1229df8ab85405514f (patch) | |
tree | 01772f3da000f7296bffde3a53c4f4c52a11dd9f /examples | |
parent | Renamed 'vmime::platformDependant' to 'vmime::platform'. (diff) | |
download | vmime-6139afdbf8a0fced0cb31f1229df8ab85405514f.tar.gz vmime-6139afdbf8a0fced0cb31f1229df8ab85405514f.zip |
Updated example and doc with some code showing how to read embedded object data from a file.
Diffstat (limited to 'examples')
-rw-r--r-- | examples/example3.cpp | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/examples/example3.cpp b/examples/example3.cpp index 3b9d2d26..bc9aa4a0 100644 --- a/examples/example3.cpp +++ b/examples/example3.cpp @@ -73,8 +73,21 @@ int main() // -- embed an image (the returned "CID" (content identifier) is used to reference // -- the image into HTML content). - vmime::string cid = textPart.addObject("<...IMAGE DATA...>", - vmime::mediaType(vmime::mediaTypes::IMAGE, vmime::mediaTypes::IMAGE_JPEG)); + vmime::utility::fileSystemFactory* fs = + vmime::platform::getHandler()->getFileSystemFactory(); + + vmime::ref <vmime::utility::file> imageFile = + fs->create(fs->stringToPath("/path/to/image.jpg")); + + vmime::ref <vmime::utility::fileReader> fileReader = + imageFile->getFileReader(); + + vmime::ref <vmime::contentHandler> imageCts = + vmime::create <vmime::streamContentHandler> + (fileReader->getInputStream(), imageFile->getLength()); + + const vmime::string cid = textPart.addObject(imageCts, + vmime::mediaType(vmime::mediaTypes::IMAGE, vmime::mediaTypes::IMAGE_JPEG)); // -- message text textPart.setText(vmime::create <vmime::stringContentHandler> |