Comments (3)
Hi there,
I'm afraid I don't have time right now to test your scenario, but perhaps you can try this that I've got somewhere on the wiki :
Open the plugin registration tool and register a new step under BinaryStorageOptions.Plugin.
Message = Retrieve
Primary Entity = template
Post Operation / Synchronous
Remember to add the secure and unsecure config xml.
You can test with just this, and you can add one more for "RetrieveMultiple" with the same settings.
Basically, this will tell CRM to use the plugin when reading templates, which is where I can see the email templates are stored at. I'm not certain whether your problem is on the read or create message, but I'm guessing it will actually be on the read.
Let me know how that goes.
Cheers.
Update.
Had a very quick look at this, and it seems the system creates new emails when you run a campaign. Since there's no plugins associated with campaigns, doesn't look like the email attachments work. I will see what I can do about this, can't give you a timeframe atm though...
from dynamics-crm-binary-storage-options.
Update 2.
If you look in the V5 branch here :
I've added a new method :
private Tuple<int, byte[]> SearchForAttachment(IOrganizationService service, Providers.IBinaryStorageProvider storageProvider, Entity entity, string documentBodyAttributeKey, string fileNameAttributeKey)
{
//This is a little bit of a hack, but there really isn't very many good options.
//When there's an error loading an email attachment, there's a good chance that crm is requesting a duplicate of an existing attachment, as that's how it seems to be stored.
//So, go through the list of activitymimeattachments pointing to the same attachment id, and see if you can get the binary data using that.
using (OrganizationServiceContext context = new OrganizationServiceContext(service))
{
var attachmentId = ((EntityReference)(from ama in context.CreateQuery(CrmConstants.AttachmentEntityName)
where ((EntityReference)ama[CrmConstants.AttachmentEntityId]).Id == entity.Id
select ama[CrmConstants.AttachmentId]).FirstOrDefault()).Id;
var activitymimeattachmentIds = (from ama in context.CreateQuery(CrmConstants.AttachmentEntityName)
where (Guid)ama[CrmConstants.AttachmentId] == attachmentId
select ama[CrmConstants.AttachmentEntityId])
.ToList();
foreach (Guid activitymimeattachmentId in activitymimeattachmentIds)
{
try
{
int fileSize = storageProvider.GetFileSize(activitymimeattachmentId, (string)entity.Attributes[fileNameAttributeKey]);
byte[] data = storageProvider.Read(activitymimeattachmentId, (string)entity.Attributes[fileNameAttributeKey]);
return new Tuple<int, byte[]>(fileSize, data);
}
catch { }
}
}
return null;
}
And it's called in the catch block of the "HandleEntity" method above :
if (entity.LogicalName == CrmConstants.AttachmentEntityName)
{
//Search for other attacments pointing to the same attachment id (not the activitymimeattachment).
var otherData = SearchForAttachment(service, storageProvider, entity, documentBodyAttributeKey, fileNameAttributeKey);
if (otherData != null && entity.Attributes.ContainsKey(fileNameAttributeKey))
{
if (entity.Attributes.ContainsKey(CrmConstants.FileSizeKey) &&
(int)entity.Attributes[CrmConstants.FileSizeKey] == GenericConstants.EmptyBodyContentDataLength)
{
entity.Attributes[CrmConstants.FileSizeKey] = otherData.Item1;
}
if (entity.Attributes.ContainsKey(documentBodyAttributeKey) &&
(string)entity.Attributes[documentBodyAttributeKey] == GenericConstants.EmptyBodyContent)
{
entity.Attributes[documentBodyAttributeKey] = Convert.ToBase64String(otherData.Item2);
}
return;
}
}
You'll also need to add some constants in CrmConstants :
public const string AttachmentEntityId = "activitymimeattachmentid";
public const string AttachmentId = "attachmentid";
This seems to fix the reading issues I can see for campaign generated emails. It's a bit of a hack, but it seems to work.
Hope it helps.
from dynamics-crm-binary-storage-options.
Hi there,
Did you try the fix? Can I close the ticket perhaps?
from dynamics-crm-binary-storage-options.
Related Issues (20)
- Question with Dynamics 365 and checking CRM storage HOT 6
- Question: Attachment Searchability HOT 4
- Has the 5Mb limit been fixed? HOT 2
- Attachments on an inactive e-mail HOT 14
- 3 Plugin steps is Async and does not fire HOT 9
- Update email attachment when email is in pending send state. HOT 3
- Provider Type: AzureBlob error HOT 1
- Delete annotation/note HOT 3
- Plugin on create HOT 4
- Access Question HOT 2
- failed to 'Retrieve' for 'activitymimeattachment'. HOT 5
- Only small storage gained - Dynamics 365 (Online) HOT 3
- Dynamics 365 Online - The authentication endpoint Kerberos was not found on the configured Secure Token Service HOT 3
- CRM online backward compatibility HOT 3
- Question about the move annotation feature HOT 8
- The wiki page issues HOT 1
- Migration doesn't do anything HOT 6
- Migration 4.1 does not work with CRM online HOT 2
- Problem with IfdSelected variable in Migrate Solution HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from dynamics-crm-binary-storage-options.