#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 );
msg.Display( _variant_t( (bool)1 ) );
_NameSpace ns = app->GetNamespace("MAPI");
MAPIFolder folder = ns.GetDefaultFolder( olFolderInbox );
folder.Display();
}
|