Dyetech

...colourful technology...

Emailing Sales Literature #2

CRM 4.0 can't attach sales literature to emails - something that seems to be "obvious" - what's the point of being able to store sales literature in the CRM system (as a "repository") without being able to email it to contacts?

[Note: you can - just download onto your hard disk, then attach to email - but hang on - that defeats the whole object!!!]

Step #2: Custom Plugin

A plugin lets us run custom routines during various "events": in this case we're interested in Create and Update of the email entity (and post-event).

The steps we need are:

  1. Check that the plugin is running from post-create or post-update of the email entity
  2. Obtain the "activityid" of the email (Guid)
  3. Obtain the "new_salesliteratureid" (Lookup) of the Sales literature item the user wishes to attach
  4. Obtain the count of the number of existing attachments on the email
  5. Retrieve the item(s) attached to the sales literature; and attach them to the email

The easiest way to show this is to simply post the C# code used - no warranties or guarantees; it has comments but does require a degree of knowledge of CRM 4.0 plugins.  Of course if you know a better way of doing it we'd love to know.

There are plenty of interesting items in this code; such as the fact that by doing it using a plugin (we've also demonstrated this using a workflow and Javascript) it happens on the server; and we've avoided actually downloading the attachment to disk.  There are 'catches' such as the name of an attribute changing between create and update.

This plugin needs registering - we use the CRM SDK tools.

Technologies

  • Visual Basic
  • C, C++, C#
  • WinForms
  • SQL
  • CRM 4.0