Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics CRM (Archived)

Send notes attachment via email using Plugin

Posted on by 3,610

I have following snippet to get the attached document of notes of an Order. Now, I want to attach this document in a email using plugin. Any idea/suggestion to attach this document to email attachment.

	EntityCollection results = null;
	QueryExpression query = new QueryExpression
    {
		EntityName = "annotation",
		ColumnSet = new ColumnSet("subject", "filename", "notetext", "documentbody"),
		Criteria = new FilterExpression
		{
			Conditions = {
		new ConditionExpression {
			AttributeName ="objectid",
			Operator = ConditionOperator.Equal,
			Values = { order }
		},
		new ConditionExpression {
			AttributeName = "isdocument",
			Operator = ConditionOperator.Equal,
			Values = { true}
		}
			}
		}
    };

    results = service.RetrieveMultiple(query);


*This post is locked for comments

  • Suggested answer
    Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Send notes attachment via email using Plugin

    please find the detailed steps for your req: community.dynamics.com/.../sending-email-with-entity-attachment-from-notes

  • Inogic Profile Picture
    Inogic 24,094 on at
    RE: Send notes attachment via email using Plugin

    Hi Mohsin,


    You can use following code to create email attachment

    Entity attachement = new Entity("activitymimeattachment");
    //Here notesbody is text of notes
    attachement["body"] = notesBody;
    tracingService.Trace("body");

    attachement["filename"] = "mime-attachment.txt";
    tracingService.Trace("file");

    attachement["objectid"] = new EntityReference("email", emailId);
    tracingService.Trace("object id");

    attachement["objecttypecode"] = "email";
    tracingService.Trace("type code");

    attachement["subject"] = subjectData;
    tracingService.Trace("subject");

    attachement["mimetype"] = "text/calendar";
    tracingService.Trace(“Before creating Attachment”);

    service.Create(attachement);

    tracingService.Trace("Attachment created");

    You can also refer the below link:
    https://rajeevpentyala.com/tag/activitymimeattachment/ 

    Hope this helps!

    Thanks!

    Sam

  • Suggested answer
    ScottDurow Profile Picture
    ScottDurow 50,177 on at
    RE: Send notes attachment via email using Plugin

    Hi  Mohsin,

    You need to create an ActivityMimeAttachment and set the body to the documentbody of the note - there is a sample in the SDK - msdn.microsoft.com/.../gg328344.aspx

    Hope this answers your question!

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,269 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,198 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans