Changing the sender of a Dynamics CRM e-mail in a plugin? - dynamics-crm

So, here's my situation. We have a department that needs the ability to use queues in CRM 4. They also need the ability to reply to e-mails that come to that queue from their department e-mail address. (So that any customer responses will go back to the queue to be handled by agents)
I originally was going to build a JavaScript customization that inserted a checkbox that said "Send From Business Unit". Toggling this would look up their department user based on the e-mail address on the Business Unit. I successfully got this working (as a concept), but found that actually sending triggers the dreaded "CrmCheckPrivilege failed."
Which is good, because that means CRM is actually enforcing security.
So my problem? I have no idea how to replicate this functionality and it's a must have for this customer group. Is there anyway to modify the e-mail after it's already gone through security checks via a plugin? Perhaps a pre-stage send plugin?
I want to be reasonably certain of success before I commit a lot of time to this solution. I'm also open to any other ideas too.
Thanks in advance,
Clif

Well, first, a "CrmPrivilegeCheck failed" can always be fixed by adjusting the user's roles and giving him the appropriate privilege (the privilegeId is always returned in the exception but may not be shown in the particular error dialog you are getting) and level, but this may not be wanted by the department.
A solution we have used is just slightly different from yours: Do not send the mails through another user, but through the queue. Queues can also be eMail senders in MSCRM. The queues should already have the correct eMail addresses set in order to work properly with the eMail router. Set up a way to determine the correct queue (like a field on the systemuser entity or a hardcoded queue name in your JavaScript) and set the from lookup accordingly in your JavaScript. That way the eMails will be sent using the name and address of the queue, so any direct replies will always have that queue as the recipient.

Related

How to get conversation id if we only have send-only permission of user outlook account?

Is it possible to get conversation id and message id of the messages sent by our app on behalf of the user who only given send only permission?
We want to send follow-up mails in the same conversation and there is no way we can do that without message id.
I'm afraid not. You need to have mail.read in order to find the message id and add to the conversation.
Also, it's important to note that the id is mutable and can change for any number of reasons (most commonly the mail item being moved to another folder). It is possible to get immutable identifiers for Outlook resources but this functionality is still in Preview so, for the time being, it really shouldn't be used in a production environment.

Approval link in email body

Need help in implementing email based approval system. Ex: Manager gets an auto triggered mail for his/her approval with a approval link in email body, when the manager clicks on the the link, it should validate the manager and then approve it. I tried searching on the internet but didn't find relevant resource.
Request you to Please help me with your ideas, suggestions or how I should proceed, or any plugin or jar is available??? It would be very helpful to me... Thanking you...
EDIT: Thanking you for replying. We have a java web app build using spring framework (MVC) where in employees can apply leaves which has to be approved by his/her manager. If an employee applies leave then a mail is triggered for approval to his/her manager with the leave details. After looking the mail, the manager logs-in to the application to approve or reject the leaves. So request you to Please help me in how to give a direct link in the mail to approve or reject the leaves.
For one of our applications we had the same requirements - employees can submit vacation requests and supervisors will be notified via mail. We have written an article about the exact way we did it - available here.
So in a nutshell, we are using Spring Integration and GMail. Each new vacation request yields an email send to all supervisors. Supervisors can reply with either approve or reject. We only accept email addresses from our domain, but since these can be faked we introduced a shared secret - a UUID added to the mail's subject which then relates to the id of the vacation request.
Once an email comes in we run the business logic to figure out whether a request shall be approved or rejected.
As I stated in my comment, I used Velocity to template my email message. You don't have to use it, but it made my job easier. You should be able to read up on it.
Java itself has the ability to send emails in it's Java EE framework using JavaMail, or you can use Spring's wrappers. You will need access to a mail server of some sorts, and would highly recommend that you setup an email box specifically for this process. I actually used my gmail account during testing, but I wouldn't recommend that for a long-term solution. I assume your company would have an email server setup somewhere you can use.
The process flow would be:
Employee fills out request
System generates an email to employee's manager(s) with a link to approve
Manager clicks on link, taken to approval page
Manager approves/denies request
The next question is how to build the URL. I would suggest using something like a UUID or something like that, or the request ID if that makes it easier. You can generate a UUID from any seed String or set of bytes. I like UUID because it obviscates the data being sent.
Anyway, the URL will basically point to a Spring form that will allow the user to approve that request. So, thinking about what you would need, I would expect some DB record that relates the information in the incoming request to the time off request that was filled out. Read in the record, load the page and display it. Simple enough.
The next issue is locking it down so only the authorized people can approve. Again, making a huge assumption here, but I am guessing you are using Spring Security? If you are, you should be able to add a condition to the Controller's handler for this approval form that requires the user to be authenticated (read here) and add a java.security.Principal to the handler methods arguments (read 15.3.2.3 here for what you can pass into a Controller's handler). With the Principal object in-hand, you should be able to compare that to a list of approvers associated with the request record in the DB. I would then have the system generate approval/denial emails that code to all concerned parties.
Let me reiterate that this is NOT the only solution, only one possible solution. This is why I feel this is not a good question for StackOverflow, as it asks a very broad question that doesn't really have a single right answer.

Can we prevent duplicate cases which are built by the email to case using email services?

using the salesforce Email Services can we do means prevent duplicate cases and How please???
I understand your pain. My users often complain that our service email address is included in email conversations and this creates a case for each email received. They then have to spend hours merging the cases and pulling out the relavant material. Worse, they have to manually move email attachments from the duplicate child case to the parent case.
One solution is to purchase an AppExchange application that provides a custom email handler that works well. Look for the Email to Case premium on the AppExchange.
https://sites.secure.force.com/appexchange/listingDetail?listingId=a0N30000001R5cyEAC
Or you can do what I did and build a custom email handler. See my blog for the code which is currently working in our organization:
http://sforcehacks.blogspot.com/2012/01/email-to-case-can-create-too-many-cases.html

MVC: Where to trigger user registration emails

I am building an MVC application (using the Zend Framework).
When users first register, the applicaiton sends them an email. My question is, where should I trigger this email from? The model or the controller? My thoughts are as follows:
In some ways, the model makes sense, since sending a registration email is part of my business logic. Users must click the link in the mail to validate their email address.
But by putting it in the model, I am 'encumbering' the model. The model's registerUser action is then only useful within the context of an application that needs emails sent for every registration.
Instead, by triggering the email from within the controller, my controller would be a litter 'fatter', but my model a little more 'fine grained'.
I have written an email service which actually configures and sends the email, and I think this is a good design decision. I am really just asking where I should be calling this service from.
Your thoughts are most appreciated!
According to Zend Framework's definition of MVC, you should put send the email from the controller:
Controllers...decide which view to display based on the user's request.
Models, on the other hand, contain:
...basic functionality behind a set of abstractions.
An email may be considered a "view" in that it displays information to the user. It is the controller's job to activate this "view."
In my opinion, I would want this in the model, as I would consider this an assumed process of the create user method, rather than any specific interaction with the user making the request.
In other words, since I would always want this email sent, regardless of the source of the request, I would identify this as a natural byproduct of the create user action, similar to a record being saved in a database.
You might want to look into using something like NServiceBus to queue messages to be sent to your Email Service.
This way you can have NServiceBus subscribe to an event that occurs and omit any manual firing of the email service etc.
Ultimately you want a failsafe way of ensuring your messages get to the intended people. This kind of framework will greatly help you ensure that this happens.
Alternatively you could store the emails to be sent inside your database and have your email service check the database queue every x minutes for new emails to send and omit the need for triggering the email sending.
Again, doing it this way will ensure at the least that the emails get sent. Should the network go down or some other disruption occur during the sending of each email you can simply leave them in the queue until the network comes back up.

How does the CRM Email router set the RegardingObjectId on incoming emails

We have a system setup where complaints from a website form are emailed to an address and subsequently picked up by the email router and placed in a queue. Users then create a case from these emails (custom code create the case and populates it based on the email content and the queue it arrived into)
Some of the emails are coming in and the regarding object is set to an existing case even though the email and the case are not related. My guess is that this is something to do with the fact that the emails are coming into the queue from the same web address (complaints#abc.com)
Can somebody explain to me the criteria the email router uses for setting the regarding object of an incoming email
Thanks,
Neil
Looks like you are another "victim" of a feature called Smart Matching. For info on what that is and how to disable it, look here.

Resources