CRM2013使用代码为Email实体添加Excel附件
Workflow使用:
private void addAttachment(Guid emailId, List<string> excel, IOrganizationService service)
{
Entity attachmentEntity = new Entity("activitymimeattachment");
string strPath = excel[1];//Excel 文件包含地址
var extension = Path.GetExtension(strPath).ToLower();//截取文件后缀名
string attachmentName = Path.GetFileName(strPath);//文件名称(包含后缀)
switch (extension)
{
case ".xls":
attachmentEntity.Attributes["mimetype"] = "application/vnd.ms-excel";
break;
case ".xlsx":
attachmentEntity.Attributes["mimetype"] = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
break;