vc 发送email outlook express 6 msimn.exe

在程序中发送邮件有很多种方法,总结如下:
1,HINSTANCE hinst=ShellExecute(NULL,NULL,_T("mailto:fyzh84@126.com?subject=Contact I

Like It&cc=&bcc=&body="),NULL,NULL,SW_SHOWNORMAL);
这种方法使用的是shell,没有指定任何程序。
2,HINSTANCE hinst=ShellExecute(NULL,_T("C://Program Files//Outlook

Express//msimn.exe"),_T("/mailurl:fyzh84@126.com"),NULL,SW_SHOWNORMAL);
3,如果你想要添加附件之类的高级功能,那么建议你使用MAPI开头的windowsAPI来实现。例子代

码:
void   __fastcall   TForm_MainForm::ToolButton_SendToClick(TObject   *Sender)
{
                MapiRecipDesc   *OriginatorRecipDesc=new   MapiRecipDesc;
                MapiRecipDesc   *recipientRecipDesc=new   MapiRecipDesc;
//                 MapiFileDesc   *FileDesc=new   MapiFileDesc;
                MapiMessage   aMapiMessage;

                //接收人信息:
                recipientRecipDesc-> ulReserved=0;
                recipientRecipDesc-> ulRecipClass=MAPI_TO;                
                recipientRecipDesc-> lpszName=NULL;// "xthmpro_cn ";
                recipientRecipDesc-> lpszAddress= "SMTP:xthmpro_cn@sina.com ";//Name  

or   Address   can   set   noly   one;
                recipientRecipDesc-> ulEIDSize=0;
                recipientRecipDesc-> lpEntryID=NULL;
                               
                //发送人信息:
                OriginatorRecipDesc-> ulReserved=0;
                OriginatorRecipDesc-> ulRecipClass=MAPI_ORIG;
                OriginatorRecipDesc-> lpszName=NULL;
                OriginatorRecipDesc-> lpszAddress= "SMTP:xthmpro_cn@sina.com ";//Name 

 or   Address   can   set   noly   one;
                OriginatorRecipDesc-> ulEIDSize=0;
                OriginatorRecipDesc-> lpEntryID=NULL;
               
                //Email内容:
                aMapiMessage.ulReserved=0;
                aMapiMessage.lpszSubject= "Hello! ";
                aMapiMessage.lpszNoteText= "OK! ";
                aMapiMessage.lpszMessageType=NULL;                
                aMapiMessage.lpszDateReceived= "2002/9/6/   22:50 ";                
                aMapiMessage.lpszConversationID=NULL;
                aMapiMessage.flFlags=MAPI_RECEIPT_REQUESTED;                  
                aMapiMessage.lpOriginator=OriginatorRecipDesc;            
                aMapiMessage.nRecipCount=1;                
                aMapiMessage.lpRecips=recipientRecipDesc;                
                aMapiMessage.nFileCount=0;//     1            
                aMapiMessage.lpFiles=NULL;//FileDesc;  

                aMessage.Handle=Handle;
                aMessage.aMapiMessage=aMapiMessage;

                DWORD   SendMailThreadID;
                HANDLE   Hthread=CreateThread

(0,0,SendMailThreadFunc,&aMessage,0,&SendMailThreadID);//参数一定要使用全局变量!
                if(Hthread==NULL)
                                Application-> MessageBox( "Error ",NULL,   MB_OK);
}
//---------------------------------------------------------------------------
DWORD   CALLBACK   SendMailThreadFunc(void   *aMessage)
{
                AMessage   *aaMessage=(AMessage   *)aMessage;
               
                FLAGS   flFlags=MAPI_DIALOG   |   MAPI_NEW_SESSION   |  

MAPI_LOGON_UI;
                return   MapiSendMail(NULL,(unsigned)aaMessage-> Handle,aaMessage->

aMapiMessage,flFlags,0);
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值