locked
ActivityMimeAttachement + showing 0 bytes for docx in CRM 2011 RRS feed

  • Question

  • Hi,

    I have writtend custom workflow where sending emails with attachments. Everything works fine except in crm activities attached .docx showing 0 bytes.

    Need help.


    If you find this post helpful then please "Vote as Helpful" and "Mark As Answer". Thanks and Regards, Yogesh Vijay Mulay

    Monday, December 30, 2013 11:11 AM

All replies

  • Hello,

    Could you please provide the code you use to generate attachments?


    Dynamics CRM MVP/ Technical Evangelist at SlickData LLC
    My blog

    Monday, December 30, 2013 11:34 AM
    Moderator
  •                 // Create the 'From:' activity party for the email
                    Entity Fromparty = new Entity("activityparty");
                    Entity Toparty = new Entity("activityparty");

                    Toparty["partyid"] = new EntityReference("contact", contactEmailId);
                    Fromparty["partyid"] = new EntityReference("systemuser", UserId);

                    // Create an e-mail message.
                    Entity email = new Entity("email");
                    email["from"] = new Entity[] { Fromparty };
                    email["to"] = new Entity[] { Toparty };
                    email["subject"] = "Business Support Word Report Creation";
                    email["description"] = "This email used to send word report for business support";
                    email["directioncode"] = true;
                    email["mimetype"] = @"application\ms-word";
                    email["regardingobjectid"] = new EntityReference("iba_businesssupport", businessSupportId);

                    Guid emailId = service.Create(email);

                    //Email Attachment
                    Entity EmailAttachment = new Entity("activitymimeattachment");
                    EmailAttachment["objectid"] = new EntityReference("email", emailId);
                    EmailAttachment["objecttypecode"] = "email";
                    EmailAttachment["subject"] = "Email Attachment";
                    //EmailAttachment["body"] = System.Convert.ToBase64String(new ASCIIEncoding().GetBytes("Example Attachment"));
                    EmailAttachment["filename"] = filePath;
                    service.Create(EmailAttachment);

                    SendEmailRequest sendEmailreq = new SendEmailRequest
                    {
                        EmailId = emailId,
                        TrackingToken = "",
                        IssueSend = true
                    };
                    SendEmailResponse sendEmailresp = (SendEmailResponse)service.Execute(sendEmailreq);


    If you find this post helpful then please "Vote as Helpful" and "Mark As Answer". Thanks and Regards, Yogesh Vijay Mulay

    Monday, December 30, 2013 12:22 PM
  • Hello,

    I believe that size equals to 0 because you've commented line

    EmailAttachment["body"] = System.Convert.ToBase64String(new ASCIIEncoding().GetBytes("Example Attachment"));

    That means that file is empty and it's size equals to 0.


    Dynamics CRM MVP/ Technical Evangelist at SlickData LLC
    My blog

    Monday, December 30, 2013 12:56 PM
    Moderator
  • Hi,

    I am confused what to write in "Example Attachment".

    Could you please help.?


    If you find this post helpful then please "Vote as Helpful" and "Mark As Answer". Thanks and Regards, Yogesh Vijay Mulay

    Monday, December 30, 2013 1:52 PM
  • You will have to read content of some file inside.

    Dynamics CRM MVP/ Technical Evangelist at SlickData LLC
    My blog

    Monday, December 30, 2013 2:26 PM
    Moderator