asinro
March 18th, 2002, 06:17 AM
Hi
I use "cdonts.h" & INewMail class to create my object
Send gives "serious error" & recepient doesn't receive anything
I work on WIN2000 workStation & used a type library "..\WINNT\system32\cdonts.dll"
Pl. look into this
Thanks...
if(S_OK != CoInitialize(NULL) )
{
AfxMessageBox("CoInitialize Fail");
return;
}
INewMail MailObj ;
COleException* pError = NULL;
pError = new COleException;
BOOL bVal = MailObj.CreateDispatch("CDONTS.NewMail", pError);
if (bVal)
{
CString Sender = "aaa@bb.com" ;
VARIANT VFrom ;
VFrom.bstrVal = Sender.AllocSysString() ;
VFrom.vt = VT_BSTR ;
CString Recipient = "ccc@bb.com" ;
VARIANT VTo ;
VTo.bstrVal = Recipient.AllocSysString() ;
VTo.vt = VT_BSTR ;
CString Subject = "Test Message" ;
VARIANT VSubject ;
VSubject.bstrVal = Subject.AllocSysString() ;
VSubject.vt = VT_BSTR ;
CString Body = "Test Body" ;
VARIANT VBody ;
VBody.bstrVal = Body.AllocSysString() ;
VBody.vt = VT_BSTR ;
MailObj.SetBodyFormat(1);
int Importance = 1 ;
VARIANT VImportance ;
VImportance.intVal = Importance ;
VImportance.vt = VT_I4 ;
try
{
MailObj.Send ( VFrom , VTo , VSubject , VBody , VImportance ) ;
AfxMessageBox("Send success");
}
catch( COleDispatchException e)
{
TCHAR szCause[1000];
CString strFormatted;
e.GetErrorMessage(szCause, 1000);
strFormatted = _T("Info = ");
strFormatted += szCause;
AfxMessageBox(strFormatted);
}
catch(...)
{
AfxMessageBox("Send FAIL - serious error");//gives this error
}
I use "cdonts.h" & INewMail class to create my object
Send gives "serious error" & recepient doesn't receive anything
I work on WIN2000 workStation & used a type library "..\WINNT\system32\cdonts.dll"
Pl. look into this
Thanks...
if(S_OK != CoInitialize(NULL) )
{
AfxMessageBox("CoInitialize Fail");
return;
}
INewMail MailObj ;
COleException* pError = NULL;
pError = new COleException;
BOOL bVal = MailObj.CreateDispatch("CDONTS.NewMail", pError);
if (bVal)
{
CString Sender = "aaa@bb.com" ;
VARIANT VFrom ;
VFrom.bstrVal = Sender.AllocSysString() ;
VFrom.vt = VT_BSTR ;
CString Recipient = "ccc@bb.com" ;
VARIANT VTo ;
VTo.bstrVal = Recipient.AllocSysString() ;
VTo.vt = VT_BSTR ;
CString Subject = "Test Message" ;
VARIANT VSubject ;
VSubject.bstrVal = Subject.AllocSysString() ;
VSubject.vt = VT_BSTR ;
CString Body = "Test Body" ;
VARIANT VBody ;
VBody.bstrVal = Body.AllocSysString() ;
VBody.vt = VT_BSTR ;
MailObj.SetBodyFormat(1);
int Importance = 1 ;
VARIANT VImportance ;
VImportance.intVal = Importance ;
VImportance.vt = VT_I4 ;
try
{
MailObj.Send ( VFrom , VTo , VSubject , VBody , VImportance ) ;
AfxMessageBox("Send success");
}
catch( COleDispatchException e)
{
TCHAR szCause[1000];
CString strFormatted;
e.GetErrorMessage(szCause, 1000);
strFormatted = _T("Info = ");
strFormatted += szCause;
AfxMessageBox(strFormatted);
}
catch(...)
{
AfxMessageBox("Send FAIL - serious error");//gives this error
}