使用CDO发邮件附件
下边是一段大家都知道的c#中使用cdo发邮件的方式。
那么哪位知道。怎么在里边加入一段代码就可以让他同时可以发送附件了啊?
private bool CDOsendMail()
{
try
{
CDO.Message oMsg = new CDO.Message();
oMsg.HTMLBody="html";
CDO.IConfiguration iConfg = oMsg.Configuration;
ADODB.Fields oFields = iConfg.Fields;
oFields["http://schemas.microsoft.com/cdo/configuration/sendusing"].Value=2;
oFields["http://schemas.microsoft.com/cdo/configuration/sendemailaddress"].Value=mailadd; //sender mail
oFields["http://schemas.microsoft.com/cdo/configuration/smtpaccountname"].Value=mailadd; //email account
oFields["http://schemas.microsoft.com/cdo/configuration/sendusername"].Value=mailadd;
oFields["http://schemas.microsoft.com/cdo/configuration/sendpassword"].Value=pwd;
oFields["http://schemas.microsoft.com/cdo/configuration/smtpauthenticate"].Value=1;
//value=0 代表Anonymous验证方式(不需要验证)
//value=1 代表Basic验证方式(使用basic (clear-text) authentication.
//The configuration sendusername/sendpassword or postusername/postpassword fields are used to specify credentials.)
//Value=2 代表NTLM验证方式(Secure Password Authentication in Microsoft Outlook Express)
oFields["http://schemas.microsoft.com/cdo/configuration/languagecode"].Value=0x0804;
oFields["http://schemas.microsoft.com/cdo/configuration/smtpserver"].Value=ipadd;
oFields.Update();
oMsg.BodyPart.Charset="gb2312";
oMsg.HTMLBodyPart.Charset="gb2312";
oMsg.Send();
oMsg = null;
return true;
}
catch (Exception e)
{
throw e;
}
}