Universal Document Converter
Informazioni sul prodotto
Scarica
Acquista
Tutorial
Soluzioni per sviluppatori
Servizio di assistenza
Chi è fCoder SIA


      Cerca nel sito
   


      Conversioni più richieste
Da Adobe PDF a JPEG
Da documento Word a PDF
Da foglio di lavoro Excel a PDF
Da PowerPoint a JPEG
Da disegno Visio a PDF
Da disegno AutoCAD a TIFF
Da pagina Web a JPEG
Convertire di lavoro Excel in PDF
Convertire da DjVu in PDF
Pagine Web in PDF



Pagina principale>Developer Solutions>Post-Print Examples

Attach Image File to Outlook Message


Universal Document Converter is virtual printer software that saves any document you print as a raster PDF or an image file. You can use a post-print feature of Universal Document Converter to apply additional processing to every output file. The example below is just one of many post-print processing solutions. Please let us know if you cannot find the solution you need.

// Microsoft Office Outlook 2000 or above should be installed
//
// 1) Open your project in Microsoft Visual C++ 6.0
//
// 2) Press "Ctrl+W" in Visual C++ to open ClassWizard
//
// 3) In ClassWizard window press "Add Class->From a type library"
//    button and select "MSOUTL.OLB" file.
//
// 5) Save files "msoutl.h" and "msoutl.cpp" and add into
//    your "stdafx.h" file this include: #include "msoutl.h"
//
// 6) You must initialize the COM before you call any COM method.
//    Please call "::CoInitialize(0);" before using COM and
//    ::CoUninitialize(); after using COM.

#include "msoutl.h"
#include <comdef.h>

enum OlAttachmentType
{
  olByValue = 1,
  olByReference = 4,
  olEmbeddedItem = 5,
  olOLE = 6
};

enum OlDefaultFolder
{
  olFolderDeletedItems = 3,
  olFolderOutbox = 4,
  olFolderSentMail = 5,
  olFolderInbox = 6,
  olFolderCalendar = 9,
  olFolderContacts = 10,
  olFolderJournal = 11,
  olFolderNotes = 12,
  olFolderTasks = 13,
  olFolderDrafts = 16
};

enum OlItemType
{
  olMailItem = 0,
  olAppointmentItem = 1,
  olContactItem = 2,
  olTaskItem  = 3,
  olJournalItem = 4, 
  olNoteItem = 5,
  olPostItem = 6
};

void CreateMsg(char* subj, char* body, char* email, char* filePath)
{
  _Application* app = new _Application;
  app->CreateDispatch( "Outlook.Application" );
////
  _MailItem msg = app->CreateItem( olMailItem );
  msg.SetTo( email );
  msg.SetSubject( subj );	
////
  Attachments atts = msg.GetAttachments();
  
  CString sFileName = filePath;
  sFileName = sFileName.Mid( sFileName.ReverseFind('\\') + 1 );

  atts.Add( _variant_t(filePath), _variant_t( (long)olByValue ),\
            _variant_t("1"), _variant_t(sFileName) );
////
  msg.SetBody( body );
// Show message modal and wait when user send or close it
  msg.Display( _variant_t( (bool)1 ) );

// Show Outlook for message sending
  _NameSpace ns = app->GetNamespace("MAPI");
  MAPIFolder folder = ns.GetDefaultFolder( olFolderInbox );
  folder.Display();
}



Related topics
Popular pages
Popular solutions


© fCoder SIA Chi è fCoder SIA | Mappa del sito