//See the previous blog about how to create new email
GUID emailID = CreateEmail(toUsers, ccUsers, subject, body);
//Pass contactID
Guid contactID = new Guid(paramValue);
//Pass contactID
Guid contactID = new Guid(paramValue);
private AddNotesAttachmentinEmail(GUID emailID, GUID contactID)
{
using (XrmServiceContext xsContext = new XrmServiceContext(CRMServiceProxy))
{
var qry = from anno in xsContext.AnnotationSet
where anno.contact_Annotations.contactid == contactID
&& anno.IsDocument == true
&& anno.MimeType != null
select new
{
anno.Subject,
anno.MimeType,
anno.FileName,
anno.DocumentBody
};
foreach (var rec in qry)
{
ActivityMimeAttachment ama = new ActivityMimeAttachment();
ama.Subject = rec.Subject;
ama.ObjectId = new EntityReference("email", emailID);
ama.ObjectTypeCode = "email";
ama.FileName = rec.FileName;
ama.Body = rec.DocumentBody;
ama.MimeType = rec.MimeType;
CRMServiceProxy.Create(ama);
}
}
}
{
using (XrmServiceContext xsContext = new XrmServiceContext(CRMServiceProxy))
{
var qry = from anno in xsContext.AnnotationSet
where anno.contact_Annotations.contactid == contactID
&& anno.IsDocument == true
&& anno.MimeType != null
select new
{
anno.Subject,
anno.MimeType,
anno.FileName,
anno.DocumentBody
};
foreach (var rec in qry)
{
ActivityMimeAttachment ama = new ActivityMimeAttachment();
ama.Subject = rec.Subject;
ama.ObjectId = new EntityReference("email", emailID);
ama.ObjectTypeCode = "email";
ama.FileName = rec.FileName;
ama.Body = rec.DocumentBody;
ama.MimeType = rec.MimeType;
CRMServiceProxy.Create(ama);
}
}
}
No comments:
Post a Comment