Créer un mail via une appli C++

Cedced41 Messages postés 2 Date d'inscription mercredi 13 juillet 2005 Statut Membre Dernière intervention 3 octobre 2005 - 26 sept. 2005 à 16:01
Cedced41 Messages postés 2 Date d'inscription mercredi 13 juillet 2005 Statut Membre Dernière intervention 3 octobre 2005 - 3 oct. 2005 à 11:14
Bonjour ,

Je souhaite créer un mail via mon appli C++ sous pocket PC 2003.
mon appli s'appelle : PROJET

Actuellement j'arrive à créer le mail avec tous les paramêtres, mais il se place dans le dossier "BROUILLON" du compte "Courrier Outlook"
alors que je voudrais qu'il se place dans le répertoire "Boîte d'envoi" du dossier "PROJET" que j'ai paramêtré précédement.

voici mon code source :


Citation:
,
----

/////////////////////////////////////////////////////////////////////////////
// Function name : CMailObj::SubmitMail
// Description : Creates a new message in the message store
//
// Return type : BOOL - RETURNS TRUE if Successful, FALSE otherwise.
//
// Argument : LPTSTR lpszTo - Pointer to a string containing
// Recipient's Name.
//
// Argument : LPTSTR lpszSubject - Pointer to a string containing
// the Message Subject.
//
// Argument : LPTSTR lpszBody - Pointer to a string containing
// the Body of the Message.
//
// Argument : LPTSTR lpszAttach - Pointer to a string containing
// the path & file of the attachment.
//
BOOL CEMailHandler::SubmitMail(LPTSTR lpszTo, LPTSTR lpszSubject, LPTSTR lpszBody, LPTSTR lpszAttachPath)
{
BOOL bReturn = TRUE;
HANDLE phNewMail = NULL;
MailMsg Msg;
MailAtt MAtt;

// Check for an attachment
if (*lpszAttachPath)
{
// Clear the MailAtt Structure
memset(&MAtt, 0, sizeof(MailAtt));

// Setup the Mail Attachment Structure
MAtt.uiAttachmentNumber = 1;
MAtt.dwFlags = NULL;
//MAtt.ulCharacterPosition; // NOT SUPPORTED YET!
MAtt.ulSize = NULL; // Not needed since we are sending a local file

// MAtt.szOriginalName = TEXT("Pièce jointe");
MAtt.szOriginalName = lpszAttachPath;

MAtt.szLocalName = lpszAttachPath;

}
// Open the message store and obtain a handle to the mail context
bReturn = MailOpen ( &phNewMail, TRUE );

// Check for Success
if ( ( bReturn ) && ( NULL != phNewMail ) )
{
bReturn = FALSE;

// Clear the MailMsg
memset ( &Msg, 0, sizeof ( MailMsg ) );

// Specify which transport service we want to send the message.
Msg.szSvcNam = TEXT("Projet");

// Specify that we want the msg placed in the Outbox to be sent.
Msg.dwFlags = MAIL_FOLDER_OUTBOX | MAIL_STATUS_COMPOSED;

// Set the pointer to the Body of the message.
Msg.szBody = lpszBody;

// Set our Header up.
bReturn = MailSetField ( &Msg, TEXT( "To" ), lpszTo );
bReturn = MailSetField ( &Msg, TEXT( "Subject" ), lpszSubject );

// Set Date
SYSTEMTIME tTime;
FILETIME ftTime;
GetSystemTime(&tTime);

SystemTimeToFileTime(&tTime, &ftTime);
Msg.ftDate = ftTime;

// Place the message on the message store.
bReturn = MailPut ( phNewMail, &Msg );
if (( bReturn ) && ( NULL != &Msg ))
{
if(*lpszAttachPath)
{
#ifdef _DEBUG
char outstring[300];
wsprintf((unsigned short*)outstring, L"Attachment Path = \"%s\" \n", MAtt.szLocalName);
OutputDebugString((unsigned short *)outstring);
#endif
// Note that MailPutAttachment will attach the file to
// the mailmsg and also DELETE THE ORIGINAL FILE.
// You might want to copy the original file
// before attaching it. Also note that since it deletes
// the original, you will get an error when attempting
// to attach a file that exists on ROM.
bReturn = MailPutAttachment(phNewMail, &Msg, &MAtt);
}
}
}

// Release our new Mail Handle
if(phNewMail) MailClose(phNewMail);

return bReturn;

}

Le code "Msg.szSvcNam = TEXT("Projet");" devrait indiquer le nom du dossier dans lequel copier le mail mais apparement cela ne marche pas.
il se place toujours dans le dossier "Courrier Outlook" par défaut.

Merci à tout ceux qui tenterons de m'aider.

2 réponses

cs_AlexMAN Messages postés 1536 Date d'inscription samedi 21 décembre 2002 Statut Membre Dernière intervention 24 mai 2009 1
26 sept. 2005 à 22:26
Tentative dans le vent je pense : il ne faudrait pas respecter la casse ? Msg.szSvcNam = TEXT("PROJET"); ?

+2(p - n)
0
Cedced41 Messages postés 2 Date d'inscription mercredi 13 juillet 2005 Statut Membre Dernière intervention 3 octobre 2005
3 oct. 2005 à 11:14
Malheuresement cela ne règle pas mon problème.
J'ai utiliser ce code sur une machine ARM autre qu'un pocket PC et cela fonctionne très bien.

Le problème est donc lié au systemen Pcoket PC 2003...

Personne n'a une solution ?
0
Rejoignez-nous