Forum |  HardWare.fr | News | Articles | PC | S'identifier | S'inscrire | Shop Recherche
2804 connectés 

  FORUM HardWare.fr
  Programmation
  C++

  Plug-in Outlook MAPI : récuperer les infos d'un mail non encore envoyé

 


 Mot :   Pseudo :  
 
Bas de page
Auteur Sujet :

Plug-in Outlook MAPI : récuperer les infos d'un mail non encore envoyé

n°290038
hastur
Posté le 20-01-2003 à 15:58:09  profilanswer
 

Bonjour,
Je suis en train de developper un plugin outlook en utilisant MAPI.
J'ajoute un bouton sur la fenetre d'envoi d'un nouveau message.
En gros, lorsque l'utilisateur a fini de remplir son nouveau message, il clique sur mon bouton au lieu de cliquer sur le bouton "envoyer" classique.
 
La je dois récuperer les infos entrées par l'utilisateur (to, cc, bcc, sujet et corps du message).
Pour cela je récupere un pointeur sur l'objet IMessage  sensé contenir les infos du message mais apparement, les infos n'y sont pas ...
 voici mon code : lorsque l'utilisateur clique sur mon bouton, la fonction DoCommand est appelée.

Code :
  1. STDMETHODIMP OutlookExtension::DoCommand(LPEXCHEXTCALLBACK pmecb, UINT cmdid)
  2. {
  3. LPMDB lpMDB = NULL;
  4. LPMESSAGE lpMsg = NULL;
  5. HRESULT hr = S_FALSE;   // assume it is not our command
  6. if (m_cmdidEnvoi == cmdid)
  7. {
  8. pmecb->GetObject(&lpMDB, (LPMAPIPROP *)&lpMsg);
  9. GetMsgInfo(lpMsg);
  10. if (NULL != lpMDB)
  11.  lpMDB->Release();
  12. if (NULL != lpMsg)
  13.  lpMsg->Release();
  14. hr = S_OK;
  15. }
  16. else if(m_cmdidOption == cmdid)
  17. {
  18. MessageBox(m_hWnd, "Test Option", "Extension PosteCs Outlook", MB_OK);
  19. hr = S_OK;
  20. }
  21. return hr;
  22. }
  23. void OutlookExtension::GetMsgInfo(LPMESSAGE lpMsg)
  24. {
  25.     LPSPropValue        lpPropVals = NULL;
  26.     SPropValue        val;
  27. ULONG               ulPropCount= 0;
  28. //LPSPropTagArray MsgPropTagArray;
  29. HRESULT hr;
  30. SizedSPropTagArray(1, MsgPropTagArray) = {1,
  31.         {PR_NORMALIZED_SUBJECT}
  32. };
  33. // hr = lpMsg->SaveChanges(KEEP_OPEN_READWRITE );
  34. CStdString valeur(_T("Propriété du message :\n" ));
  35. //get message subject
  36. hr = lpMsg->GetProps((SPropTagArray*)&MsgPropTagArray, 0, &ulPropCount, &lpPropVals);
  37. if (hr==MAPI_E_NO_ACCESS)
  38.  MessageBox(m_hWnd, "MAPI_E_NO_ACCESS", "Extension PosteCs Outlook", MB_OK);
  39. else if (hr==MAPI_W_ERRORS_RETURNED)
  40.  MessageBox(m_hWnd, "MAPI_W_ERRORS_RETURNED", "Extension PosteCs Outlook", MB_OK);
  41. else
  42. {
  43.  for(int i=0; i<ulPropCount; i++)
  44.  {
  45.   val = lpPropVals[i];
  46.   if((val.ulPropTag != PT_ERROR ) && (val.Value.lpszA != NULL))
  47.   {
  48.    valeur += val.Value.lpszA;
  49.    valeur += "\n";
  50.   }
  51.  }
  52. }
  53. // Get the body of the message as plain text
  54. // into the buffer 'bodybuf'
  55. char *bodybuf=0; unsigned int bodysize=0;
  56. IStream *istream;
  57. hr = lpMsg->OpenProperty(PR_BODY, &IID_IStream, STGM_READ, 0, (IUnknown**)&istream);
  58. if (hr==S_OK)
  59. {
  60.   STATSTG stg = {0};
  61.   hr = istream->Stat(&stg,STATFLAG_NONAME);
  62.   if (hr==S_OK)
  63.   { bodysize = stg.cbSize.LowPart; // won't bother checking for >2gb messages!
  64.  bodybuf = new char[bodysize+1];
  65.  ULONG red; hr = istream->Read(bodybuf, bodysize, &red);
  66.  if (hr!=S_OK) bodysize=0;
  67.  else if (red<bodysize) bodysize=red;
  68.  bodybuf[bodysize]=0;
  69.   }
  70.   istream->Release();
  71. }
  72. //get recipients to, cc and bcc
  73. CStdString to, cc, bcc;
  74. IMAPITable *rtable;
  75. hr = lpMsg->GetRecipientTable(0,&rtable);
  76. if (hr==S_OK)
  77. { SizedSPropTagArray(2,rcols) = {2, {PR_RECIPIENT_TYPE, PR_EMAIL_ADDRESS} };
  78.   SRowSet *rrows;
  79.   hr = pHrQueryAllRows(rtable,(SPropTagArray*)&rcols,NULL,NULL,0,&rrows);
  80.   if (hr==S_OK)
  81.   { for (unsigned int r=0; r<rrows->cRows; r++)
  82.  {
  83.    if (rrows->aRow[r].lpProps[0].ulPropTag==PR_RECIPIENT_TYPE)
  84.    {
  85.     if(rrows->aRow[r].lpProps[0].Value.l == MAPI_TO)
  86.      if (rrows->aRow[r].lpProps[1].ulPropTag==PR_EMAIL_ADDRESS)
  87.      {
  88.       to += rrows->aRow[r].lpProps[1].Value.lpszA;
  89.      }
  90.     else if(rrows->aRow[r].lpProps[0].Value.l == MAPI_CC)
  91.      if (rrows->aRow[r].lpProps[1].ulPropTag==PR_EMAIL_ADDRESS)
  92.      {
  93.       cc += rrows->aRow[r].lpProps[1].Value.lpszA;
  94.      }
  95.     else if(rrows->aRow[r].lpProps[0].Value.l == MAPI_BCC)
  96.      if (rrows->aRow[r].lpProps[1].ulPropTag==PR_EMAIL_ADDRESS)
  97.      {
  98.       bcc += rrows->aRow[r].lpProps[1].Value.lpszA;
  99.      }
  100.    }
  101.  }
  102.  pFreeProws(rrows);
  103.   }
  104.   rtable->Release();
  105. }
  106. MessageBox(m_hWnd, (LPCTSTR )valeur, "Extension PosteCs Outlook", MB_OK);
  107. MessageBox(m_hWnd, bodybuf, "Extension PosteCs Outlook", MB_OK);
  108. MessageBox(m_hWnd, to, "Extension PosteCs Outlook : TO", MB_OK);
  109. MessageBox(m_hWnd, cc, "Extension PosteCs Outlook : CC", MB_OK);
  110. MessageBox(m_hWnd, bcc, "Extension PosteCs Outlook : BCC", MB_OK);
  111. MAPIFreeBuffer(lpPropVals);
  112. }


Message édité par hastur le 20-01-2003 à 17:11:32
mood
Publicité
Posté le 20-01-2003 à 15:58:09  profilanswer
 

n°290176
hastur
Posté le 20-01-2003 à 18:33:08  profilanswer
 

Personne pour m'aider ?  :(

n°290683
hastur
Posté le 21-01-2003 à 12:10:45  profilanswer
 

:pfff:


Aller à :
Ajouter une réponse
  FORUM HardWare.fr
  Programmation
  C++

  Plug-in Outlook MAPI : récuperer les infos d'un mail non encore envoyé

 

Sujets relatifs
fonction mail en php sur multimania[PHP] Récuperer le texte d'un fichier sur un autre serveur
Serveur SMTP pour fonction mail() de PHP ?[php/MysqL] récuperer une valeur directement
[JS] Récupérer la hauteur d'un div[java]récupérer la date d'un fichier ?
envoyer un mail par script .VBSActive Directory - récuperé/insérer des infos depuis un panel WEB
Recuperer l'url contenue dans une iframe [ Remote Scripting ? ][Access] Récupérer le contenu d'une liste
Plus de sujets relatifs à : Plug-in Outlook MAPI : récuperer les infos d'un mail non encore envoyé


Copyright © 1997-2022 Hardware.fr SARL (Signaler un contenu illicite / Données personnelles) / Groupe LDLC / Shop HFR