📄 faxmail.cpp
字号:
// sub=pFrom;
// AfxMessageBox(sub.operator const char *());
}
}
else
{ ////////转换不成,发回通知
DeleteFile(path1+".bfx");
sub="传真发送失败:文件格式不对,或不能转换成传真";
pMsg->put_Subject(sub.operator wchar_t *());
pMsg->Send();
// pMsg->Release();
// pMsgs->Delete(iMsg);
}
if(!bBFX)
DeleteFile(path1+xn); ///删除接收到的附件
}
break;//结束提取传真文件
}
else ///附件扩展名称不对
{
if(i==iBody-1) ////最后的附件名称也不对,回信告警
{
sub="传真发送失败:格式不对";
pMsg->put_Subject(sub.operator wchar_t *());
pMsg->Send();
// pMsg->Release();
// pMsgs->Delete(iMsg);
// break;
}
}
} ////测试附件
}
// pMsg->Release();
bodys1=NULL;
pMsg=NULL;
pMsgs->Delete(iMsg);
} /////测试每封来信
// pMsgs->Release();
pMsgs=NULL;
//pDropDir->Release();
}
catch(CDBException* e)
{
// AfxMessageBox(e->m_strError);
e->Delete();
bDBException=true;
// db.Close();
// db.Open(m_DSN);
}
catch(_com_error e)
{
AfxMessageBox(e.ErrorMessage( ));
}
catch(...)
{
// pMsgs->Release();
// pDropDir->Release();
AfxMessageBox("....");
}
}
return 0;
}
UINT __cdecl MyFaxTX( LPVOID pParam )
{
CFaxSrvView * pView=(CFaxSrvView*)pParam;
while(1)
{
Sleep(1000);
/////////读通道信息
try
{/////////保正线程不中断
}
catch(CDBException* e)
{
}
catch(...)
{
}
}
return 0;
}
UINT __cdecl MyFaxNotice( LPVOID pParam )
{
CFaxSrvView * pView=(CFaxSrvView*)pParam;
CoInitialize(NULL);
IDropDirectoryPtr pDropDir;
IMessagePtr pMsg(__uuidof(Message));//IMessagesPtr pMsgs ;
IUnknown* pUnk ;
IEnumVARIANTPtr pEnum ;
IConfigurationPtr pConf;
pConf.CreateInstance(L"CDO.Configuration");
pConf->Load(cdoOutlookExpress,_bstr_t(""));
FieldsPtr pf1;
pConf->get_Fields(&(pf1));
FieldPtr pf2;
pf1->get_Item(_variant_t(cdoSendUsingMethod),&pf2);
pf2->put_Value(_variant_t((long)cdoSendUsingPort));
// pf1->get_Item(_variant_t(cdoSendUsingMethod),&pf2);
// pf2->get_Value();
pf1->Update();
/////////////////////////
pMsg->putref_Configuration (pConf); /////完成配置
CDatabase db;
db.OpenEx(m_DSN);//"DSN=faxdata"UID=sa;PWD=;
CFaxBill faxBill(&db);
CFaxRecv faxRecv(&db);
CFaxError faxError(&db);
CFaxUser faxUser(&db);
while(1)
{
try
{
Sleep(1000);
/////////读通道信息
/* CoCreateInstance(
__uuidof(DropDirectory),
NULL,
CLSCTX_SERVER,
__uuidof(IDropDirectory),
(void**)&pDropDir);
*/
/////获取数据库恢复信息,发送邮件用户
///////发送传真成功,提示 fax_bill
//// 只回复传真文件名还是原文
faxBill.m_strFilter="notice='no'";
if(faxBill.IsOpen())
faxBill.Requery();
else
faxBill.Open();
while(!faxBill.IsEOF())
{
faxUser.m_strFilter.Format("userid='%s'",faxBill.m_userid);
if(faxUser.IsOpen())
faxUser.Requery();
else
faxUser.Open();
if(!faxUser.IsEOF())
{////写Message,send
_bstr_t to(faxUser.m_usermail);
pMsg->put_To((wchar_t*)(to));
// _bstr_t from("lgy@chinalyp.com");
// pMsg->put_From((wchar_t*)(from));
_bstr_t sub("传真已发送报告(to:");
sub+=LPCTSTR(faxBill.m_faxto);
sub+=")";
pMsg->put_Subject((wchar_t*)(sub));
// pMsg->AddAttachment("http://example.microsoft.com/picture.gif","","");
// pMsg->AddAttachment("file://d:/temp/test.doc","","");
_bstr_t att(faxBill.m_faxdoc);
IBodyPartPtr pBody;
pMsg->AddAttachment((wchar_t*)(att),NULL,NULL,&pBody);
pMsg->Send();
IBodyPartsPtr pBodys;
pMsg->get_Attachments(&pBodys); //pBody->get_BodyParts(&pBodys);
pBodys->DeleteAll();
faxBill.Edit();
faxBill.m_notice="已通知";
faxBill.Update();
}
else ///无法回复
{
faxBill.Edit();
faxBill.m_notice="无邮件地址";
faxBill.Update();
}
faxBill.MoveNext();
}
///////发送三次失败的,通知用户,并列入失败表 fax_error
//// 只回复传真文件名还是原文
faxError.m_strFilter="notice='no'";
if(faxError.IsOpen())
faxError.Requery();
else
faxError.Open();
while(!faxError.IsEOF())
{
faxUser.m_strFilter.Format("userid='%s'",faxError.m_userid);
if(faxUser.IsOpen())
faxUser.Requery();
else
faxUser.Open();
if(!faxUser.IsEOF())
{////写Message,send
_bstr_t to(faxUser.m_usermail);
pMsg->put_To((wchar_t*)(to));
// _bstr_t from("lgy@chinalyp.com");
// pMsg->put_From((wchar_t*)(from));
_bstr_t sub("传真发送失败报告(to:");
sub+=LPCTSTR(faxError.m_faxto);
sub+=")";
pMsg->put_Subject((wchar_t*)(sub));
// pMsg->AddAttachment("http://example.microsoft.com/picture.gif","","");
// pMsg->AddAttachment("file://d:/temp/test.doc","","");
_bstr_t att(faxError.m_faxdoc);
IBodyPartPtr pBody;
pMsg->AddAttachment((wchar_t*)(att),NULL,NULL,&pBody);
pMsg->Send();
IBodyPartsPtr pBodys;
pMsg->get_Attachments(&pBodys); //pBody->get_BodyParts(&pBodys);
pBodys->DeleteAll();
faxError.Edit();
faxError.m_notice="已通知";
faxError.Update();
}
else ///无法回复
{
faxError.Edit();
faxError.m_notice="无邮件地址";
faxError.Update();
}
faxError.MoveNext();
}
//////////////////////bak
///////接收传真,传回给用户 fax_recv
faxRecv.m_strFilter="notice='no'";
if(faxRecv.IsOpen())
faxRecv.Requery();
else
faxRecv.Open();
while(!faxRecv.IsEOF())
{
faxUser.m_strFilter.Format("userid='%s'",faxRecv.m_userid);
if(faxUser.IsOpen())
faxUser.Requery();
else
faxUser.Open();
if(!faxUser.IsEOF())
{////写Message,send
_bstr_t to(faxUser.m_usermail);
pMsg->put_To((wchar_t*)(to));
_bstr_t from("lgy@chinalyp.com");
pMsg->put_From((wchar_t*)(from));
_bstr_t sub("传真邮件");
pMsg->put_Subject((wchar_t*)(sub));
// pMsg->AddAttachment("http://example.microsoft.com/picture.gif","","");
// pMsg->AddAttachment("file://d:/temp/test.doc","","");
_bstr_t att(faxRecv.m_faxdoc);
IBodyPartPtr pBody;
pMsg->AddAttachment((wchar_t*)(att),NULL,NULL,&pBody);
pMsg->Send();
IBodyPartsPtr pBodys;
pMsg->get_Attachments(&pBodys); //pBody->get_BodyParts(&pBodys);
pBodys->DeleteAll();
faxRecv.Edit();
faxRecv.m_notice="已通知";
faxRecv.Update();
}
else ///无法回复
{
faxRecv.Edit();
faxRecv.m_notice="无邮件地址";
faxRecv.Update();
}
faxRecv.MoveNext();
}
}
catch(CDBException*e)
{
}
catch(...)
{
}
}
return 0;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -