HOWTO: Customizing the Reply To Property for a Message

ID: Q165350


The information in this article applies to:
  • Extended Messaging Application Programming Interface (MAPI), version 1.0


SUMMARY

There may be times when you want to force the reply of a message to a particular person or distribution list. You can accomplish this by using the PR_REPLY_RECIPIENT_NAMES property of the message.


MORE INFORMATION

You can set the PR_REPLY_RECIPIENT_NAMES property by using code. It should be noted that the code sample below is not a complete working program and it assumes that you have a handle to a MAPI session.

  1. Add the PR_REPLY_RECIPIENT_NAMES to the SPropValue array.
    
         pspvOut[OBSENTREP].ulPropTag = PR_REPLY_RECIPIENT_NAMES; 


  2. Set the value of the PR_REPLY_RECIPIENT_NAMES property. This property will contain the Display Name of the recipients.
    
         pspvOut[OBSENTREP].Value.lpszA = "[SMTP:testing@Microsoft.com]"; 


  3. Create an ADRLIST structure containing the address or addresses to reply to.

    NAME, ADDR, EMAIL, RECIP are part of an enum of the recipient properties.
    
          LPADRLIST  pAdrList = NULL;
          if (FAILED(hRes = MAPIAllocateBuffer(CbNewSRowSet(1),
                                              (LPVOID*) &pAdrList)))
              goto Quit;
    
          if (FAILED(hRes = MAPIAllocateBuffer(
                   NUM_RECIP_PROPS * sizeof(SPropValue),
                  (LPVOID*) &(pAdrList->aEntries[0].rgPropVals) )))
              goto Quit;
    
          pAdrList->cEntries = 1;
          pAdrList->aEntries[0].cValues = 4;
          pAdrList->aEntries[0].rgPropVals[NAME].ulPropTag = PR_DISPLAY_NAME;
          pAdrList->aEntries[0].rgPropVals[NAME].Value.lpszA="Test User";
          pAdrList->aEntries[0].rgPropVals[ADDR].ulPropTag = PR_ADDRTYPE;
          pAdrList->aEntries[0].rgPropVals[ADDR].Value.lpszA = "SMTP";
          pAdrList->aEntries[0].rgPropVals[EMAIL].ulPropTag = PR_EMAIL_ADDRESS;
          pAdrList->aEntries[0].rgPropVals[EMAIL].Value.lpszA = "";
          pAdrList->aEntries[0].rgPropVals[RECIP].ulPropTag =
                 PR_RECIPIENT_TYPE;
          pAdrList->aEntries[0].rgPropVals[RECIP].Value.l = MAPI_TO; 


  4. Call ResolveName to get ENTRYIDs for the addresses.
    
          hRes = m_pAddrBook->ResolveName(NULL,MAPI_DIALOG,
                                          "Resolve Names",pAdrList); 


  5. Set the properties of the outbound message.
    
          if (FAILED(hRes = pMsg ->
              SetProps(NUM_OUTBOUND_PROPS,pspvOut,&pPropProblemArray)))
            goto Quit;
    
          hRes = pMsg -> ModifyRecipients(0,pAdrList); 



REFERENCES

Microsoft Developer Network, WIN32 SDK

Additional query words:

Keywords : kbprg kbMsg kbMAPI100
Version : WINDOWS:1.0
Platform : WINDOWS
Issue type : kbhowto


Last Reviewed: November 9, 1999
© 2000 Microsoft Corporation. All rights reserved. Terms of Use.