Exemple #1
0
        private void SendEmailByDraft(Entity entity)
        {
            tracingService.Trace("EmailSender.SendEmailByDraft()");
            try
            {
                GetTrackingTokenEmailRequest  trackingTokenEmailRequest  = new GetTrackingTokenEmailRequest();
                GetTrackingTokenEmailResponse trackingTokenEmailResponse = null;

                var draftEmailReq = new SendEmailRequest
                {
                    EmailId   = entity.Id,
                    IssueSend = true,
                };

                trackingTokenEmailResponse = (GetTrackingTokenEmailResponse)service.Execute(trackingTokenEmailRequest);

                // setting email tracking token
                draftEmailReq.TrackingToken = trackingTokenEmailResponse.TrackingToken;

                // send request
                service.Execute(draftEmailReq);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Exemple #2
0
        /// <summary>
        /// Retrieve a <c>Tracking Token</c> that can be passed in as a parameter to the <see cref="SendEmailRequest"/> message, and also <see cref="Send(Entity, string, EntityReference)"/> method.
        /// <para>
        /// For more information look at https://msdn.microsoft.com/en-us/library/microsoft.crm.sdk.messages.gettrackingtokenemailrequest(v=crm.8).aspx
        /// </para>
        /// </summary>
        /// <param name="subject">Email subject</param>
        /// <returns><c>Tracking token</c> for email 's subject (<see cref="string"/>)</returns>
        public string GetTrackingToken(string subject)
        {
            ExceptionThrow.IfNullOrEmpty(subject, "subject");

            GetTrackingTokenEmailRequest request = new GetTrackingTokenEmailRequest()
            {
                Subject = subject
            };

            GetTrackingTokenEmailResponse serviceResponse = (GetTrackingTokenEmailResponse)this.OrganizationService.Execute(request);

            return(serviceResponse.TrackingToken);
        }