Click here to Skip to main content
15,910,009 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: MFC Thread problem Pin
Nish Nishant15-Mar-02 13:41
sitebuilderNish Nishant15-Mar-02 13:41 
GeneralApplication as Win NT Service Pin
FutureWizard15-Mar-02 12:33
FutureWizard15-Mar-02 12:33 
GeneralRe: Application as Win NT Service Pin
Nish Nishant15-Mar-02 13:43
sitebuilderNish Nishant15-Mar-02 13:43 
GeneralCrystal Report 8.0 in VC++ .NET Pin
Hadi Rezaee15-Mar-02 10:41
Hadi Rezaee15-Mar-02 10:41 
GeneralFunction Declaration in Interface File :: MFC Pin
valikac15-Mar-02 10:40
valikac15-Mar-02 10:40 
GeneralRe: Function Declaration in Interface File :: MFC Pin
Chris Losinger15-Mar-02 11:28
professionalChris Losinger15-Mar-02 11:28 
GeneralRe: Function Declaration in Interface File :: MFC Pin
Nish Nishant15-Mar-02 13:45
sitebuilderNish Nishant15-Mar-02 13:45 
Generalusing #import to automate Outlook, but...:confused: Pin
15-Mar-02 10:19
suss15-Mar-02 10:19 
Hey all,

I am trying to use import to automate Outlook to send email for my CGI program.
However, outlook stays in memory after my program is finished and my program
got stuck with outlook too, can anybody tell me why and how to solve it?

Thanks a lot and the following is my code for sending email:


void Sendfile(){
try
{

_NameSpacePtr pNameSpace;
MAPIFolderPtr pOutbox;
_ItemsPtr pOutboxItems;
_MailItemPtr pNewMail;
AttachmentsPtr pAttachments;
RecipientsPtr pRecipients;

char eachfile[100];
char eachemail[100];
char eachcustmail[100];

int pos;

//fileLocation, set to 150 character lenght
char filelocat[250];


// Create an Outlook.Application pointer.
_ApplicationPtr pApp("Outlook.Application");

// Create NameSpace pointer.
pNameSpace = pApp->GetNamespace(L"MAPI");

// Logon in OutLook
pNameSpace->Logon(LogonTo);

// Create pointer to the Outbox Folder.
pOutbox = pNameSpace->GetDefaultFolder(olFolderOutbox);

// Create pointer to the Messages Collection.
pOutboxItems = pOutbox->Items;

// Create pointer to a new message.
pNewMail = pOutboxItems->Add();

// Set the Subject of the message.
pNewMail->Subject=subject;

// Set the Text of the message.
pNewMail->Body=body;

// Set the BCC address (already define in the header file)
pNewMail->BCC=BCC;

// Create pointer to the Attachments collection.
pAttachments = pNewMail->Attachments;

//Loop for Attachment for each file
pos=0;

while (pos <= (int)(strlen(filename)) ){

getStringNext(filename,pos,eachfile);

strcpy(filelocat,path);
strcat(filelocat,eachfile);

// printf("%s\n",filelocat);


if (IsExist_Notnull(filelocat)){
// Create new Attachment. path
pAttachments->Add(filelocat, (long)1, (long)(15000),
eachfile);
}



}//end while

// Create pointer to Recipients Collection.
pRecipients = pNewMail->Recipients;

//Loop for input string to extract mail addresses
pos=0;

while (pos <= (int)(strlen(custmail)) ){

getStringNext(custmail,pos,eachemail);

strcpy(eachcustmail,eachemail);

// printf("%s\n",filelocat);

// Add recipient.
pRecipients->Add(eachcustmail);

}//end while

// Resolve the recipient address.
pRecipients ->ResolveAll();

// Send the message.
pNewMail->Send();


// Logoff NameSpace.
pNameSpace->Logoff();

pApp->Quit();

return;
}

catch (_com_error &e)
{
dump_com_error(e);
return;
}
}//end
GeneralRe: using #import to automate Outlook, but...:confused: Pin
Bill Wilson15-Mar-02 10:38
Bill Wilson15-Mar-02 10:38 
GeneralReverse ULONG values Pin
15-Mar-02 9:45
suss15-Mar-02 9:45 
GeneralRe: Reverse ULONG values Pin
Christian Graus15-Mar-02 10:26
protectorChristian Graus15-Mar-02 10:26 
GeneralRe: Reverse ULONG values Pin
Nish Nishant15-Mar-02 13:48
sitebuilderNish Nishant15-Mar-02 13:48 
Generalmultiple adapter loopback test using CSockets Pin
gus15-Mar-02 9:13
gus15-Mar-02 9:13 
GeneralRe: multiple adapter loopback test using CSockets Pin
Tim Deveaux15-Mar-02 9:53
Tim Deveaux15-Mar-02 9:53 
GeneralRe: multiple adapter loopback test using CSockets Pin
gus15-Mar-02 10:26
gus15-Mar-02 10:26 
GeneralRe: multiple adapter loopback test using CSockets Pin
Tim Deveaux15-Mar-02 11:42
Tim Deveaux15-Mar-02 11:42 
GeneralRe: multiple adapter loopback test using CSockets Pin
gus19-Mar-02 4:15
gus19-Mar-02 4:15 
GeneralList control refresh issue Pin
Andrew Stampor15-Mar-02 8:48
Andrew Stampor15-Mar-02 8:48 
GeneralRe: List control refresh issue Pin
Shog915-Mar-02 8:59
sitebuilderShog915-Mar-02 8:59 
GeneralThread questions........... Pin
15-Mar-02 8:34
suss15-Mar-02 8:34 
GeneralRe: Thread questions........... Pin
Andres Manggini15-Mar-02 9:47
Andres Manggini15-Mar-02 9:47 
GeneralRe: Thread questions........... Pin
Nemanja Trifunovic15-Mar-02 10:19
Nemanja Trifunovic15-Mar-02 10:19 
GeneralRe: Thread questions........... Pin
Christopher Duncan15-Mar-02 11:36
Christopher Duncan15-Mar-02 11:36 
GeneralRe: Thread questions........... Pin
Tim Smith15-Mar-02 11:43
Tim Smith15-Mar-02 11:43 
GeneralRe: Thread questions........... Pin
Christopher Duncan15-Mar-02 15:23
Christopher Duncan15-Mar-02 15:23 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.