Source scenario:
In Microsoft Dynamics CRMwhich we use with our .NET application, the following system settingsfor 'Email' is: “Use smart match” was selected, and “Use tracking marker” was not selected.
Both outgoing and incoming emails worked perfectly without any problems.
Everything worked as expected, until the last week, when incoming emails stopped arriving. Therefore, as recommended by Microsoft, we changed our settings to receive incoming emails.
Scenario after changing settings:
According to Microsoft, we changed the CRM system settings to select "Use Tracking Token" and deselect "Use Smart Matching".
Incoming letters began to arrive correctly.
Question:
This time, some outgoing emails that were generated as part of the CRM data service code do not go out. Emails generated and sent by workflows will be correct.
There is no problem creating emails. But when I try to send it, it fails with the following stack trace:
: at System.ServiceModel.Channels.ServiceChannel.HandleReply(ProxyOperationRuntime , ProxyRpc & rpc) System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime, Object [] ins, [], - TimeSpan) System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage Call, ProxyOperationRuntime) System.ServiceModel.Channels.ServiceChannelProxy.Invoke( )
, [0]: at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage( reqMsg, IMessage retMsg) System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData & msgData, Int32) Microsoft.Xrm.Sdk.IOrganizationService.Execute(OrganizationRequest ) Microsoft.Xrm.Sdk.Client.OrganizationServiceProxy.ExecuteCore(OrganizationRequest ) Microsoft.Xrm.Sdk.Client.OrganizationServiceProxy.Execute(OrganizationRequest ) CRMDataService.Classes.EmailFunctions.CreateAndSendEmail(CrmErrorHandler logger, String emailBody, String emailSubject, KeyValuePair 2
fromParty, Dictionary 2 toParties, 2 ccParties, Dictionary 2 bccParties, Nullable 1 regardingObject, Nullable 1 , Boolean bSendEmail, String trackingToken, Email emailFromTemplate, Nullable`1 & emailGuid) C:\Users\vnarkar\Workspace\CRMDataService\Classes\EmailFunctions.cs: 115
, :
if (bSendEmail) {
SendEmailRequest sendEmailReq = new SendEmailRequest();
sendEmailReq.EmailId = emailID;
sendEmailReq.IssueSend = true;
sendEmailReq.TrackingToken = !String.IsNullOrWhiteSpace(trackingToken) ? trackingToken : String.Empty;
proxy.Execute(sendEmailReq);
}
proxy.Execute(sendEmailReq);
: proxy OrganizationServiceProxy.
:
var proxy = CRMHelper.GetCrmServiceProxy();
GetServiceProxy() CRMHelper:
public static OrganizationServiceProxy GetCrmServiceProxy()
{
OrganizationServiceProxy proxy = null;
try
{
ServerConnection serverConnect = new ServerConnection();
ServerConnection.Configuration serverConfig = CachedData.GetServerConfiguration();
proxy = new OrganizationServiceProxy(serverConfig.OrganizationUri, serverConfig.HomeRealmUri, serverConfig.Credentials, serverConfig.DeviceCredentials);
proxy.ServiceConfiguration.CurrentServiceEndpoint.Behaviors.Add(new ProxyTypesBehavior());
proxy.Timeout = new TimeSpan(0, 10, 0);
}
catch (FaultException<Microsoft.Xrm.Sdk.OrganizationServiceFault>)
{
}
return proxy;
}
?
(1) , , , sendEmailReq.TrackingToken.
:
GetTrackingTokenEmailRequest jj_GetTrackingTokenEmailRequest = new GetTrackingTokenEmailRequest();
GetTrackingTokenEmailResponse jj_GetTrackingTokenEmailResponse = null;
jj_GetTrackingTokenEmailResponse = (GetTrackingTokenEmailResponse) proxy.Execute(jj_GetTrackingTokenEmailRequest);
sendEmailReq.TrackingToken = jj_GetTrackingTokenEmailResponse.TrackingToken;
:
jj_GetTrackingTokenEmailResponse = (GetTrackingTokenEmailResponse) proxy.Execute(jj_GetTrackingTokenEmailRequest);
, proxy OrganizationProxy . .
(2) , , CRM. ( OrganizationService) ( OrganizationProxy). :
newEmail.RegardingObjectId = new EntityReference(SalesOrder.EntityLogicalName, so.Id);
Guid newEmailId = service.Create(newEmail);
try {
SendEmailRequest sendEmailReq = new SendEmailRequest();
sendEmailReq.EmailId = newEmailId;
sendEmailReq.IssueSend = true;
sendEmailReq.TrackingToken = String.Empty;
service.Execute(sendEmailReq);
}
, .