public IRecipientOption AddBcc(string emailAddress, string name = null)
        {
            if (BccAddresses == null)
            {
                BccAddresses = new List <EmailAddress>();
            }

            var bccAddress = new EmailAddress(emailAddress, name);

            BccAddresses.Add(bccAddress);
            return(this);
        }
示例#2
0
        public override string SerializePayload()
        {
            Dictionary <string, string> dict = new Dictionary <string, string>();

            // email formats are EMAIL1:NAME1|EMAIL2:NAME2|EMAIL3:NAME3
            dict.Add("ToAddresses", ToAddresses != null ? string.Join("|", ToAddresses.Select((kv) => EscapeString(kv.Key) + ":" + EscapeString(kv.Value))) : "");
            dict.Add("CcAddresses", CcAddresses != null ? string.Join("|", CcAddresses.Select((kv) => EscapeString(kv.Key) + ":" + EscapeString(kv.Value))) : "");
            dict.Add("BccAddresses", BccAddresses != null ? string.Join("|", BccAddresses.Select((kv) => EscapeString(kv.Key) + ":" + EscapeString(kv.Value))) : "");
            dict.Add("Subject", Subject ?? "");
            dict.Add("Body", Body ?? "");
            dict.Add("FromAddress", FromAddress ?? "");
            dict.Add("FromDisplayName", FromDisplayName ?? "");
            dict.Add("FormatAsHtml", FormatAsHtml.ToString());
            dict.Add("MailPriority", Priority.ToString("d"));

            // attachment format will be FILENAME|FILENAME|FILENAME[ATTACHMENTBOUNDARY]FILE2BYTESASSTRING[ATTACHMENTBOUNDARY]FILE2BYTESASSTRING[ATTACHMENTBOUNDARY]FILE3BYTESASSTRING
            if (Attachments != null && Attachments.Count > 0)
            {
                StringBuilder str = new StringBuilder();

                foreach (string fn in Attachments.Keys)
                {
                    byte[] fd = Attachments[fn];

                    if (str.Length > 0)
                    {
                        str.Append("|");
                    }
                    str.Append(EscapeString(fn));
                }

                foreach (string fn in Attachments.Keys)
                {
                    byte[] fd = Attachments[fn];

                    str.Append(ATTACHMENTBOUNDARY);
                    str.Append(Convert.ToBase64String(fd));
                }

                dict.Add("Attachments", str.ToString());
            }
            else
            {
                dict.Add("Attachments", "");
            }

            dict.Add("SendCcToSystemEmail", SendCcToSystemEmail.ToString());

            return(JsonConvert.SerializeObject(dict, Newtonsoft.Json.Formatting.None));
        }
        private void GenerateAddressesCollection()
        {
            foreach (var address in _checkList.ToAddresses)
            {
                ToAddresses.Add(address);
            }

            foreach (var address in _checkList.CcAddresses)
            {
                CcAddresses.Add(address);
            }

            foreach (var address in _checkList.BccAddresses)
            {
                BccAddresses.Add(address);
            }
        }
        public void ToggleSendButton()
        {
            var isToAddressesCompleteChecked  = ToAddresses.Count(x => x.IsChecked) == ToAddresses.Count;
            var isCcAddressesCompleteChecked  = CcAddresses.Count(x => x.IsChecked) == CcAddresses.Count;
            var isBccAddressesCompleteChecked = BccAddresses.Count(x => x.IsChecked) == BccAddresses.Count;
            var isAlertsCompleteChecked       = Alerts.Count(x => x.IsChecked) == Alerts.Count;
            var isAttachmentsCompleteChecked  = Attachments.Count(x => x.IsChecked) == Attachments.Count;

            if (isToAddressesCompleteChecked && isCcAddressesCompleteChecked && isBccAddressesCompleteChecked &&
                isAlertsCompleteChecked && isAttachmentsCompleteChecked)
            {
                IsCanSendMail = true;
            }
            else
            {
                IsCanSendMail = false;
            }
        }