Friday 10 June 2011

Dynamics CRM 4.0 for Outlook – Invalid Argument

If you use the From field in Microsoft Outlook while using Microsoft Dynamics CRM 4.0 and you Track the email, you may experience the following error when trying to send the email.





Invalid Argument Do you want to send the e-mail? If you click Yes, the e-mail will be sent out, but no corresponding activity will be created in Microsoft Dynamics CRM.


To begin resolving this issue I went straight to the CRM 4.0 Diagnostics Tool and ran a Trace from the Microsoft Dynamics CRM Server.  Once I had replicated the error, I Found the following error message in the trace file.

>CrmSoapExtension detected CrmException:
System.Web.Services.Protocols.SoapException: Server was unable to process request. ---> System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> Microsoft.Crm.CrmArgumentException: The specified sender type is not supported. ---> System.ArgumentException: The specified sender type is not supported.

From my own experience of troubleshooting the Email Router I knew that the Invalid sender type was like due to email address I was trying to send from was in the system twice.
To troubleshoot further I used the brilliant script provided by Ben Lec (http://blogs.msdn.com/b/benlec/archive/2008/12/23/incoming-e-mails-are-not-tracked-in-crm.aspx)
For the email address below I used the email I was trying to Send FROM (Not my own)


declare @emailAddress as varchar(100)

set @emailAddress = 'support@tnyCRM.com'

SELECT FullName, SystemUserId, InternalEmailAddress, PersonalEMailAddress
FROM SystemUserBase
WHERE InternalEMailAddress = @emailAddress
OR PersonalEMailAddress = @emailAddress


SELECT Name, QueueId, EMailAddress
FROM QueueBase
WHERE EMailAddress = @emailAddress

SELECT Name, AccountId, EMailAddress1, EMailAddress2, EMailAddress3
FROM AccountBase
WHERE EMailAddress1 = @emailAddress
OR EMailAddress2 = @emailAddress
OR EMailAddress3 = @emailAddress

SELECT FullName, ContactId, EMailAddress1, EMailAddress2, EMailAddress3
FROM ContactBase
WHERE EMailAddress1 = @emailAddress
OR EMailAddress2 = @emailAddress
OR EMailAddress3 = @emailAddress

SELECT Subject, LeadId, EMailAddress1, EMailAddress2, EMailAddress3
FROM LeadBase
WHERE EMailAddress1 = @emailAddress
OR EMailAddress2 = @emailAddress
OR EMailAddress3 = @emailAddress

In my results I found that a Queue and a User were sharing the same E-mail address.  This was creating the Invalid Argument error.  Removing the email address from the user and keeping the address in the queue enabled me to send the email.

This issue occurs because when CRM tries to send an email through outlook and the sender is support@tnyCRM.com, it will search in the whole database to see who has an email address equal to support@tnyCRM.com.
If other records, for example an Account, Lead, Contact, User or Queue are also using support@tnyCRM.com in the From field in their email, the system will not know which record to track the email against and the email will not send as Tracked.

1 comment:

  1. Great post. I had this error with the same reason.

    ReplyDelete