Thread: Creating and putting a message in the outbox.

  1. #1
    Registered User Queatrix's Avatar
    Join Date
    Apr 2005
    Posts
    1,342

    Question Creating and putting a message in the outbox.

    How can I creating a message, then put it in the outbox? (This is using Outlook Express.)

    Thanks, August.

  2. #2
    &TH of undefined behavior Fordy's Avatar
    Join Date
    Aug 2001
    Posts
    5,793
    Probably best of using CDO, but you'll have to dive into COM programming first!

  3. #3
    Registered User Queatrix's Avatar
    Join Date
    Apr 2005
    Posts
    1,342
    Cdo?

  4. #4
    &TH of undefined behavior Fordy's Avatar
    Join Date
    Aug 2001
    Posts
    5,793
    Collaborative Data Objects

    It's a library for working with Exchange, Outlook, etc

  5. #5
    Registered User Queatrix's Avatar
    Join Date
    Apr 2005
    Posts
    1,342
    So there is't some kind of folder that the outbox messages are stored in?

  6. #6
    It's full of stars adrianxw's Avatar
    Join Date
    Aug 2001
    Posts
    4,829
    Yes there is, but they are not stored as plain text. Also putting something there will acheive nothing. You need to enter into a dialogue with Outlook which requires the techniques discussed above.
    Wave upon wave of demented avengers march cheerfully out of obscurity unto the dream.

  7. #7
    Registered User Queatrix's Avatar
    Join Date
    Apr 2005
    Posts
    1,342
    I googled it, no help. I don't understand most everything discussed.
    Does anyone know of a tutorial or somthing that isn't so complicated?

  8. #8
    Yes, my avatar is stolen anonytmouse's Avatar
    Join Date
    Dec 2002
    Posts
    2,544
    The following Simple MAPI sample will add a message to the outbox of OE or whatever email client has installed itself as the default MAPI client. A security dialog will be shown before the message is sent. There are a couple of email samples here. They require the DispHelper library.
    Code:
    #include <windows.h>
    #include <mapi.h>
    #include <stdio.h>
    
    ULONG xSendEmail(PSTR szSubject, PSTR szMessage, PSTR szRecipient)
    {
    	HMODULE        hMapi         = NULL;
    	LPMAPISENDMAIL pMAPISendMail = NULL;
    	MapiMessage    msg           = { 0 };
    	MapiRecipDesc  recip         = { 0 };
    
    	recip.ulRecipClass = MAPI_TO;
    	recip.lpszAddress  = szRecipient;
    
    	msg.lpszSubject  = szSubject;
    	msg.lpszNoteText = szMessage;
    	msg.nRecipCount  = 1;
    	msg.lpRecips     = &recip;
    
    	hMapi = LoadLibrary(TEXT("mapi32.dll"));
    
    	if (hMapi)
    	{
    		pMAPISendMail = (LPMAPISENDMAIL) GetProcAddress(hMapi, "MAPISendMail");
    
    		if (pMAPISendMail)
    		{
    			return pMAPISendMail(0, 0, &msg, 0, 0);
    		}
    
    		FreeLibrary(hMapi);
    	}
    
    	return ERROR_INVALID_DLL;
    }
    
    
    int main(void)
    {
    	ULONG ret = xSendEmail("Test Message", "Hello world!\r\nThis is a test.", "[email protected]");
    
    	if (ret == SUCCESS_SUCCESS)
    	{
    		printf("Success!\n");
    	}
    	else
    	{
    		printf("Failed with error code %d.\n", ret);
    	}
    
    	getchar();
    	return 0;
    }

  9. #9
    Registered User Queatrix's Avatar
    Join Date
    Apr 2005
    Posts
    1,342
    Thanks a lot anonytmouse.

    Is there a way I can delete a message in the sent folder?

  10. #10
    Registered User Queatrix's Avatar
    Join Date
    Apr 2005
    Posts
    1,342
    also, how do you get all of the addresses in the contact list? (Buddy list)

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. How do you program a windows application?
    By Chrisab508 in forum Windows Programming
    Replies: 8
    Last Post: 10-18-2003, 10:21 AM