public static bool SendInvoiceEmail(InvoiceModel invoice)
        {
            var proxy = ServiceClientProvider.GetCommunicationServiceProxy();

            try
            {
                if (null != proxy)
                {
                    var dataToSend = ConvertInvoiceToSendData(invoice);
                    var request    = new TriggeredSendRequestRequest_V01();
                    request.Data = dataToSend;
                    var response = proxy.SendTriggeredMessage(new SendTriggeredMessageRequest(request)).SendTriggeredMessageResult;
                    if (response.Status == ServiceResponseStatusType.Success)
                    {
                        return(true);
                    }
                    else
                    {
                        LoggerHelper.Error(string.Format("CommunicationSvcProvider: Error sending Invoice Email invoice: {0}, member id: {1} status:{2}.", invoice.DisplayMemberInvoiceNumber, invoice.MemberId, response.Status));
                        return(false);
                    }
                }
                return(false);
            }
            catch (Exception ex)
            {
                LoggerHelper.Error(string.Format("CommunicationSvcProvider: Error sending Invoice Email invoice: {0}, member id: {1} Exception Message:{2}.", invoice.DisplayMemberInvoiceNumber, invoice.MemberId, ex.Message));
                return(false);
            }
        }
        public bool SendEmailConfirmation(string orderNumber, string paymentType)
        {
            var proxy = ServiceClientProvider.GetCommunicationServiceProxy();

            try
            {
                var holder = OrderProvider.GetPaymentGatewayOrder(orderNumber);
                if (holder != null)
                {
                    GdoOrderEmailSendData_V01 dataToSend = new GdoOrderEmailSendData_V01();
                    switch (paymentType)
                    {
                    case "Abandoned":
                    case "PaymentDeclined":
                    case "PaymentDeclinedOldOrder":
                    case "PaymentDeclinedMaxTries":
                        dataToSend = getDataDeclinedEmailConfirmation(holder.BTOrder, EmailDeclinedType, orderNumber);
                        break;

                    case "OrderSubmitted":
                        dataToSend = getDataEmailConfirmation(holder.BTOrder, EmailConfirmationType, orderNumber);
                        break;

                    case "Processing":
                        dataToSend = getDataInProcessingEmailConfirmation(holder.BTOrder, EmailInProcessingType, orderNumber);
                        break;
                    }

                    var request = new TriggeredSendRequestRequest_V01();
                    request.Data = dataToSend;
                    var response = proxy.SendTriggeredMessage(new SendTriggeredMessageRequest(request)).SendTriggeredMessageResult;
                    if (response.Status == ServiceResponseStatusType.Success)
                    {
                        return(true);
                    }
                    else
                    {
                        var ex = new ApplicationException(string.Format("CommunicationSvcProvider: Error sending SendTriggeredMessage order:{0}.", orderNumber));
                        WebUtilities.LogServiceExceptionWithContext(ex, proxy);
                        return(false);
                    }
                }
                return(false);
            }
            catch (Exception ex)
            {
                ex = new ApplicationException(string.Format("CommunicationSvcProvider: Error sending SendTriggeredMessage order:{0}.", orderNumber), ex);
                WebUtilities.LogServiceExceptionWithContext(ex, proxy);
                return(false);
            }
        }
        /// <summary>
        ///     Save contact confirmation email
        /// </summary>
        /// <param name="contact">Contact saved</param>
        /// <param name="distributorId">Name of the owner of the site</param>
        /// ///
        /// <param name="extension">Website extension</param>
        /// ///
        /// <param name="locale">Customer locale</param>
        /// ///
        /// <param name="domain">Domain for this locale</param>
        /// ///
        /// <param name="primaryLocale"></param>
        /// <param name="registrationSource">Where did the customer got the invitation</param>
        /// <param name="distributorName"></param>
        /// <param name="distributorEmail"></param>
        /// <param name="isDistributorCopied"></param>
        /// <returns>True if success</returns>
        public static bool SendContactConfirmationEmail(
            Contact_V01 contact,
            string distributorId,
            string extension,
            string locale,
            string domain,
            String distributorName,
            String distributorEmail,
            Boolean isDistributorCopied,
            String primaryLocale,
            RegistrationSource registrationSource = RegistrationSource.Other
            )
        {
            if (contact.EmailAddresses.Count < 1)
            {
                throw new ArgumentException("Argument can not be null", "Contact Email");
            }

            if (contact.LocalName == null)
            {
                throw new ArgumentException("Argument can not be null", "Contact Name");
            }

            if (string.IsNullOrEmpty(contact.DistributorID))
            {
                throw new ArgumentException("Argument can not be null", "Distributor ID");
            }

            var request = new TriggeredSendRequestRequest_V01();

            request.Data = new TriggeredSaveContactConformationSendData_V01
            {
                CustomerEmail       = contact.EmailAddresses[0].Address,
                CustomerName        = contact.LocalName,
                CustomerPhoneNumber =
                    (contact.Phones.Count > 0) ? contact.Phones.FirstOrDefault().Number : String.Empty,
                DistributorEmail    = distributorEmail,
                DistributorId       = distributorId,
                DistributorName     = distributorName,
                DataKey             = Guid.NewGuid().ToString(),
                Locale              = primaryLocale,
                Extension           = extension,
                IsDistributorCopied = isDistributorCopied,
                Domain              = domain,
                RegistrationSource  = registrationSource,
                EmailLanguageLocale = locale
            };

            using (var proxy = ServiceClientProvider.GetDistributorCRMServiceProxy())
            {
                try
                {
                    var response = proxy.SendTriggeredMessage(new SendTriggeredMessageRequest(request));
                    return(response.SendTriggeredMessageResult.Status == ServiceResponseStatusType.Success);
                }
                catch (Exception ex)
                {
                    Log(ex, proxy);
                    return(false);
                }
            }
        }