Call now: (800) 766-1884  


 SQL Server Tips
 SQL Server Training

 SQL Server Consulting
 SQL Server Support
 SQL Server Remote DBA

 SQL Server Scripts
 Scripts Menu




  SQL Server Tips by Gama and Naughter

Code Highlights

The code is pretty straightforward and uses the various parameters to set the attributes of the CDO message before it is sent. Some of the highlights include:

Use is made of the various XP++ macros to access the values in the ‘XP_VARIANT_PARAMETER’ structure. For example:

TCHAR* pszFrom = XP_TTEXT(m_pParameterData[FROM_INDEX].m_Data);
msg->From = pszFrom;

Special consideration needs to be given to the optional parameters. For example to use the ‘CC’ parameter, the following code is used:

if (m_pParameterData[CC_INDEX].m_bType != SRVNULL)
TCHAR* pszCC = XP_TTEXT(m_pParameterData[CC_INDEX].m_Data);
msg->CC = pszCC;

In addition some parameters, which are declared as optional in the parameter map become required, depending on the values of other parameters. For example if Basic Authentication is used to send the email, then the @User and @Password parameters to the XP should be achieved. This is accomplished using the following code:

case CDO::cdoBasic:
msg->Configuration->Fields->Item[_bstr_t("")]->Value = _variant_t(nAuthentication);
bRequiresFieldUpdate = TRUE;

if (m_pParameterData[USER_INDEX].m_bType == SRVNULL)
sprintf(szErrorMsg, "%s: \"@User\" parameter is required if using Basic Authentication", m_szFunctionName);
return FALSE;

The above book excerpt is from:

Super SQL Server Systems
Turbocharge Database Performance with C++ External Procedures

ISBN: 0-9761573-2-2
Joseph Gama, P. J. Naughter  


Burleson Consulting Remote DB Administration







Burleson is the America's Team

Note: The pages on this site were created as a support and training reference for use by our staff of DBA consultants.  If you find it confusing, please exit this page.

Errata?  SQL Server technology is changing and we strive to update our SQL Server support information.  If you find an error or have a suggestion for improving our content, we would appreciate your feedback.  Just  e-mail:and include the URL for the page.

Burleson Consulting
SQL Server database support


Copyright © 1996 -  2013 by Vaaltech Web Services. All rights reserved.

Hit Counter