Exemplo n.º 1
0
 public void Dispose()
 {
     if (_wsRecipients != null)
     {
         for (int i = 0; i < _wsRecipients.Count; i++)
             _wsRecipients[i].Dispose();
         _wsRecipients.Clear();
     }
     if (_recipients != null)
     {
         Marshal.ReleaseComObject(_recipients);
         _recipients = null;
     }
 }
Exemplo n.º 2
0
        private Recipients GetRecipientsFor(string address)
        {
            if (address != null)
            {
                Recipients recipients = RecipientFactory.getRecipientsFromString(address, false);

                if (recipients == null || recipients.IsEmpty)
                {
                    return(RecipientFactory.getRecipientsFor(Recipient.getUnknownRecipient(), false));
                }

                return(recipients);
            }
            else
            {
                //Log.w(TAG, "getRecipientsFor() address is null");
                return(RecipientFactory.getRecipientsFor(Recipient.getUnknownRecipient(), false));
            }
        }
Exemplo n.º 3
0
        public void ThrowIfInvalid()
        {
            Recipients.ThrowIfNullOrEmpty(nameof(Recipients));
            Subject.ThrowIfNullOrEmpty(nameof(Subject));
            ViewPath.ThrowIfNullOrEmpty(nameof(ViewPath));

            foreach (string recipient in Recipients)
            {
                if (!StringHelpers.IsValidEmail(recipient))
                {
                    throw new InvalidOperationException($"Email '{recipient}' is invalid");
                }
            }

            if (Cc.Any())
            {
                foreach (string cc in Cc)
                {
                    if (!StringHelpers.IsValidEmail(cc))
                    {
                        throw new InvalidOperationException($"Email '{cc}' is invalid");
                    }
                }

                Cc = Cc.Where(x => !Recipients.Contains(x)).ToArray();
            }

            if (HiddenCc.Any())
            {
                foreach (string cc in HiddenCc)
                {
                    if (!StringHelpers.IsValidEmail(cc))
                    {
                        throw new InvalidOperationException($"Email '{cc}' is invalid");
                    }
                }

                HiddenCc = HiddenCc
                           .Where(x => !Cc.Contains(x))
                           .Where(x => !Recipients.Contains(x)).ToArray();
            }
        }
Exemplo n.º 4
0
        public void Validate()
        {
            if (String.IsNullOrEmpty(SenderName))
            {
                throw new Exception("Sender name missing");
            }
            if (String.IsNullOrEmpty(SenderEmail))
            {
                throw new Exception("Sender email missing");
            }
            if (String.IsNullOrEmpty(SenderPhone))
            {
                throw new Exception("Sender phone missing");
            }
            if (String.IsNullOrEmpty(Server))
            {
                throw new Exception("Server address missing");
            }
            if (Recipients.Count() == 0)
            {
                throw new Exception("No recipients have been defined");
            }
            if (Files.Count() == 0)
            {
                throw new Exception("No files have been defined");
            }

            List <String> missingFiles = new List <string>();

            foreach (var f in Files)
            {
                if (!System.IO.File.Exists(f))
                {
                    missingFiles.Add(f);
                }
            }

            if (missingFiles.Count > 0)
            {
                throw new Exception("The following files selected for upload could not be found: " + String.Join(", ", missingFiles));
            }
        }
Exemplo n.º 5
0
        public override bool Equals(object o)
        {
            if (!(o is EmailClientSettings))
            {
                return(false);
            }
            EmailClientSettings v = o as EmailClientSettings;

            if (!AddSignature.Equals(v.AddSignature))
            {
                return(false);
            }
            if (!Content.Equals(v.Content))
            {
                return(false);
            }
            if (!Enabled.Equals(v.Enabled))
            {
                return(false);
            }
            if (!Html.Equals(v.Html))
            {
                return(false);
            }
            if (!Recipients.Equals(v.Recipients))
            {
                return(false);
            }
            if (!RecipientsBcc.Equals(v.RecipientsBcc))
            {
                return(false);
            }
            if (!RecipientsCc.Equals(v.RecipientsCc))
            {
                return(false);
            }
            if (!Subject.Equals(v.Subject))
            {
                return(false);
            }
            return(true);
        }
Exemplo n.º 6
0
        /// <summary>
        /// Binds the recipients.
        /// </summary>
        private void BindRecipients()
        {
            int recipientCount = Recipients.Count();

            lNumRecipients.Text = recipientCount.ToString("N0") +
                                  (recipientCount == 1 ? " Person" : " People");

            ppAddPerson.PersonId   = Rock.Constants.None.Id;
            ppAddPerson.PersonName = "Add Person";

            int displayCount = int.MaxValue;

            if (!ShowAllRecipients)
            {
                int.TryParse(GetAttributeValue("DisplayCount"), out displayCount);
            }

            if (displayCount > 0 && displayCount < Recipients.Count)
            {
                rptRecipients.DataSource    = Recipients.Take(displayCount).ToList();
                lbShowAllRecipients.Visible = true;
            }
            else
            {
                rptRecipients.DataSource    = Recipients.ToList();
                lbShowAllRecipients.Visible = false;
            }

            lbRemoveAllRecipients.Visible = Recipients.Where(r => r.Status == CommunicationRecipientStatus.Pending).Any();

            rptRecipients.DataBind();

            StringBuilder rStatus = new StringBuilder();

            lRecipientStatus.Text = "<span class='label label-type'>Recipient Status: " + Recipients
                                    .GroupBy(r => r.Status)
                                    .Where(g => g.Count() > 0)
                                    .Select(g => g.Key.ToString() + " (" + g.Count().ToString("N0") + ")")
                                    .ToList().AsDelimited(", ") + "</span>";

            CheckApprovalRequired(Recipients.Count);
        }
Exemplo n.º 7
0
        protected async Task CreateNewFolder()
        {
            var command = new AddFolderCommand
            {
                Name         = SelectedFolder,
                Recipients   = Recipients.Where(x => x.IsChecked).Select(x => x.Data).ToList(),
                CreateOnDisk = SelectedFolderCreationOption == FolderCreationOption.CreateNew
            };

            try
            {
                await Mediator.Send(command);

                ClearForm();
            }
            catch (ValidationException ex)
            {
                ValidationMessages = ex.Errors.Select(x => x.ErrorMessage).ToList();
            }
        }
        public override void Patch(NotificationEntity notification)
        {
            if (notification is EmailNotificationEntity emailNotification)
            {
                emailNotification.From = From;
                emailNotification.To   = To;

                if (!Recipients.IsNullCollection())
                {
                    Recipients.Patch(emailNotification.Recipients, (source, target) => source.Patch(target));
                }

                if (!Attachments.IsNullCollection())
                {
                    Attachments.Patch(emailNotification.Attachments, (source, attachmentEntity) => source.Patch(attachmentEntity));
                }
            }

            base.Patch(notification);
        }
 private void save()
 {
     if (!validate())
     {
         return;
     }
     if (recipient == null)
     {
         recipient = new Recipients();
     }
     recipient.FullName = tbxFullName.Text;
     if (recipient.save())
     {
         Close();
     }
     else
     {
         MessageBox.Show("При сохранении получателя произошли ошибки.\nПодробности см. в логе ошибок.");
     }
 }
Exemplo n.º 10
0
 public void Clear()
 {
     NameList.Clear();
     Message.Clear();
     Content = null;
     Subject = null;
     Recipients.Clear();
     ConfirmRecipientIndex     = 0;
     ShowEmailIndex            = 0;
     IsUnreadOnly              = true;
     IsImportant               = false;
     StartDateTime             = DateTime.UtcNow.Add(new TimeSpan(-7, 0, 0, 0));
     EndDateTime               = DateTime.UtcNow;
     DirectlyToMe              = false;
     SenderName                = null;
     EmailList                 = new List <string>();
     ShowRecipientIndex        = 0;
     LuisResultPassedFromSkill = null;
     MailSourceType            = MailSource.Other;
 }
Exemplo n.º 11
0
        public long GetThreadIdForRecipients(Recipients recipients, int distributionType)
        {
            long[] recipientIds = getRecipientIds(recipients);
            String recipientsList = getRecipientsAsString(recipientIds);

            try
            {
                var query = conn.Table<Thread>().Where(t => t.RecipientIds == recipientsList); // use internal property
                var first = query.Count() == 0 ? null : query.First();

                if (query != null && first != null)
                    return (long)first.ThreadId;
                else
                    return CreateForRecipients(recipientsList, recipientIds.Length, distributionType);
            }
            catch (Exception e)
            {
                throw new Exception(e.Message);
            }
        }
Exemplo n.º 12
0
        protected void checkStatus_Click(object sender, EventArgs e)
        {
            Configuration.Default.DefaultHeader.Remove("X-DocuSign-Authentication");
            Configuration.Default.AddDefaultHeader("X-DocuSign-Authentication", envelope.dsAuthHeader);

            EnvelopesApi envelopesApi = new EnvelopesApi();
            Recipients   recips       = envelopesApi.ListRecipients(envelope.dsAccountId, envelope.dsEnvelopeId);

            signer1Nametxt.InnerText = recips.Signers[0].Name;
            signer1Boxtxt.InnerText  = recips.Signers[0].Status;
            if (recips.Signers.Count == 1)
            {
                status2.Visible = false;
            }
            else
            {
                signer2Nametxt.InnerText = recips.Signers[1].Name;
                signer2Boxtxt.InnerText  = recips.Signers[1].Status;
            }
        }
Exemplo n.º 13
0
        public XElement ToXml(IToXmlContext ctx)
        {
            if (this.Attachments != null && this.Attachments.Count() > 0)
            {
                throw new NotImplementedException("Attachments are not yet exportable");
            }

            return(new XElement("EmailTemplate",
                                new XAttribute("Name", Name),
                                new XAttribute("Guid", Guid),
                                new XAttribute("DisableAuthorization", DisableAuthorization),
                                new XAttribute("Query", Query.Key),
                                new XAttribute("EditableMessage", EditableMessage),
                                Model == null ? null : new XAttribute("Model", Model.FullClassName),
                                new XAttribute("SendDifferentMessages", SendDifferentMessages),
                                MasterTemplate == null ? null : new XAttribute("MasterTemplate", ctx.Include(MasterTemplate)),
                                new XAttribute("GroupResults", GroupResults),
                                Filters.IsNullOrEmpty() ? null : new XElement("Filters", Filters.Select(f => f.ToXml(ctx)).ToList()),
                                Orders.IsNullOrEmpty() ? null : new XElement("Orders", Orders.Select(o => o.ToXml(ctx)).ToList()),
                                new XAttribute("IsBodyHtml", IsBodyHtml),
                                From == null ? null : new XElement("From",
                                                                   From.DisplayName != null ? new XAttribute("DisplayName", From.DisplayName) : null,
                                                                   From.EmailAddress != null ? new XAttribute("EmailAddress", From.EmailAddress) : null,
                                                                   From.Token != null ? new XAttribute("Token", From.Token.Token.FullKey()) : null),
                                new XElement("Recipients", Recipients.Select(rec =>
                                                                             new XElement("Recipient", new XAttribute("DisplayName", rec.DisplayName ?? ""),
                                                                                          new XAttribute("EmailAddress", rec.EmailAddress ?? ""),
                                                                                          new XAttribute("Kind", rec.Kind),
                                                                                          rec.Token != null ? new XAttribute("Token", rec.Token?.Token.FullKey()) : null
                                                                                          )
                                                                             )),
                                new XElement("Messages", Messages.Select(x =>
                                                                         new XElement("Message",
                                                                                      new XAttribute("CultureInfo", x.CultureInfo.Name),
                                                                                      new XAttribute("Subject", x.Subject),
                                                                                      new XCData(x.Text)
                                                                                      ))),

                                this.Applicable?.Let(app => new XElement("Applicable", new XCData(app.Script)))
                                ));
        }
Exemplo n.º 14
0
        public EnvelopeSummary SendDocumentB(int personType, string clientName, string clientEmail, string recipientSubject, string recipientBodyMessage)
        {
            var accountId = Credentials.AccountId;

            Template = new DocuSignTemplate(accountId, personType, clientName, clientEmail, "", "");

            var templateId    = Template.TemplateId;
            var templateRoles = Template.TemplateRoles;

            var envelopeRecipient = new Recipients()
            {
                Signers = new List <Signer>()
                {
                    new Signer()
                    {
                        ClientUserId = "1",
                        Name         = "Broker",
                        Email        = "*****@*****.**",
                        RecipientId  = "1",
                        RoleName     = "Broker",
                        Tabs         = templateRoles.FirstOrDefault().Tabs,
                    }
                }
            };

            // create a new envelope which we will use to send the signature request
            var envelope = new EnvelopeDefinition
            {
                EmailSubject = recipientSubject,
                EmailBlurb   = recipientBodyMessage,
                Recipients   = envelopeRecipient,
                //TemplateId = templateId,
                TemplateRoles = templateRoles,
                Status        = "sent"
            };

            // |EnvelopesApi| contains methods related to creating and sending Envelopes (aka signature requests)
            var envelopesApi = new EnvelopesApi();

            return(envelopesApi.CreateEnvelope(accountId, envelope));
        }
Exemplo n.º 15
0
        //  Carrier destinations
        //  ATT: Compose a new email and use the recipient's 10-digit wireless phone number, followed by @txt.att.net. For example, [email protected].
        //  Verizon: Similarly, ##@vtext.com
        //  Sprint: ##@messaging.sprintpcs.com
        //  TMobile: ##@tmomail.net

        // more info on https://www.c-sharpcorner.com/article/send-text-message-to-cell-phones-from-a-C-Sharp-application/

        public void SendThroughOUTLOOK()
        {
            subject = "Street 30 - robot support";
            message = "Need Robotic Support on W30.";

            try
            {
                // Create the Outlook application.
                oApp = new Application();
                // Create a new mail item.
                MailItem oMsg = (MailItem)oApp.CreateItem(OlItemType.olMailItem);
                // Set HTMLBody.
                //massage = "RCS, test massage!!";
                oMsg.HTMLBody = message;

                //Subject line
                //subject = "Test - Ignore.";
                oMsg.Subject = $"{subject}";

                // another way it can be done with string of arrays for several recipients:
                Recipients oRecips = (Recipients)oMsg.Recipients;
                foreach (var recipient in recipients)
                {
                    Recipient oRecip = (Recipient)oRecips.Add(recipient);
                    oRecip.Resolve();
                }
                oRecips = null;
                // Send.
                oMsg.Send();
                // Clean up.
                oMsg = null;
                oApp = null;

                Console.WriteLine("Text massage sent successfully.");
            }//end of try block
            catch (System.Exception ex)
            {
                Console.WriteLine("Text massage did not sent.");
                Console.WriteLine(ex.Message.ToString());
            } //end of catch
        }     //end of Email Method
Exemplo n.º 16
0
        protected virtual MailMessage BuildMessage(string from, Recipients recipients, IEnumerable <FileData> attachments = null)
        {
            var message = new MailMessage();

            if (!String.IsNullOrWhiteSpace(from))
            {
                var sender = new MailAddress(from);

                message.From   = sender;
                message.Sender = sender;
                message.ReplyToList.Add(sender);
            }
            else if (!string.IsNullOrWhiteSpace(this.DefaultFrom))
            {
                message.From = new MailAddress(this.DefaultFrom);
            }

            // получатели Email сообщения
            var messageRecipents = this.GetRecipents(recipients);

            if (messageRecipents == null || messageRecipents.Count <= 0)
            {
                return(null);
            }

            foreach (var r in messageRecipents)
            {
                message.To.Add(r);
            }


            if (attachments != null)
            {
                foreach (var file in attachments)
                {
                    message.Attachments.Add(new Attachment(new MemoryStream(file.Data), file.FileName));
                }
            }

            return(message);
        }
Exemplo n.º 17
0
        public void AddRecipient(string address)
        {
            string error;

            if (!MSExchangeProvider.CheckEmailAddress(address, out error))
            {
                MetroMessageBox.Show(error, "Invalid Email Address", MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }

            OrderEmailRecipient recipient = new OrderEmailRecipient();

            recipient.Address = address;
            recipient.Order   = Order;

            _db.OrderEmailRecipients.Add(recipient);
            _db.SaveChanges();

            Recipients.Add(recipient);
            InputAddress = string.Empty;
        }
Exemplo n.º 18
0
        private void AssociateMarkeitngListToMailchimpCampaign(ApiRoot root, List <List> listLists, string server, CrmEarlyBound.Campaign campaign)
        {
            List <string>     listMailchimpId = new List <string>();
            List <Conditions> listConditions  = new List <Conditions>();

            foreach (List lists in listLists)
            {
                listMailchimpId.Add(lists.find_MailChimpListId);
            }

            Conditions conditions = new Conditions("53afadfa03", listMailchimpId);

            listConditions.Add(conditions);
            SegementOps segement   = new SegementOps(listConditions);
            Recipients  recipients = new Recipients(segement);
            Campaigns   campaigns  = new Campaigns(recipients);

            Task t = Task.Run(() => root.PathCampaign(campaigns, server, campaign.find_mailChimpCampaignID));

            t.Wait();
        }
Exemplo n.º 19
0
        public void SendThroughOUTLOOK()
        {
            try
            {
                // Create the Outlook application.
                oApp = new Application();
                // Create a new mail item.
                MailItem oMsg = (MailItem)oApp.CreateItem(OlItemType.olMailItem);
                // Set HTMLBody.
                //massage = "RCS, test massage!!";
                oMsg.HTMLBody = massage;

                //Subject line
                //subject = "Test - Ignore.";
                oMsg.Subject = $"{StreetName} {subject}";
                // Add a recipient.
                //oMsg.To = "email address 1"; // several recipients: "email address 1; email address 2"
                recipients = new string[] { "email address here" };
                // another way it can be done with string of arrays for several recipients:
                Recipients oRecips = (Recipients)oMsg.Recipients;
                foreach (var recipient in recipients)
                {
                    Recipient oRecip = (Recipient)oRecips.Add(recipient);
                    oRecip.Resolve();
                }
                oRecips = null;
                // Send.
                oMsg.Send();
                // Clean up.
                oMsg = null;
                oApp = null;

                Console.WriteLine("Email sent successfully.");
            }//end of try block
            catch (System.Exception ex)
            {
                Console.WriteLine("Email did not sent.");
                Console.WriteLine(ex.Message.ToString());
            } //end of catch
        }     //end of Email Method
Exemplo n.º 20
0
        /// <summary>
        ///     Sends the mail message.
        /// </summary>
        private void _ShowMail(object ignore)
        {
            var message = new MAPIHelperInterop.MapiMessage();

            using (var interopRecipients
                       = Recipients.GetInteropRepresentation())
            {
                message.Subject  = Subject;
                message.NoteText = Body;

                message.Recipients     = interopRecipients.Handle;
                message.RecipientCount = Recipients.Count;

                // Check if we need to add attachments
                if (Files.Count > 0)
                {
                    message.Files = _AllocAttachments(out message.FileCount);
                }

                // Signal the creating thread (make the remaining code async)
                _manualResetEvent.Set();

                const int MAPI_DIALOG = 0x8;
                //const int MAPI_LOGON_UI = 0x1;
                const int SUCCESS_SUCCESS = 0;
                var       error           = MAPIHelperInterop.MAPISendMail(IntPtr.Zero, IntPtr.Zero, message, MAPI_DIALOG, 0);

                if (Files.Count > 0)
                {
                    _DeallocFiles(message);
                }

                // Check for error
                if (error != SUCCESS_SUCCESS)
                {
                    _LogErrorMapi(error);
                }
            }
        }
Exemplo n.º 21
0
        private void handleUntrustedIdentityMessage(SignalServiceEnvelope envelope, May <long> smsMessageId)
        {
            try
            {
                var                 database       = DatabaseFactory.getTextMessageDatabase(); //getEncryptingSmsDatabase(context);
                Recipients          recipients     = RecipientFactory.getRecipientsFromString(envelope.getSource(), false);
                long                recipientId    = recipients.getPrimaryRecipient().getRecipientId();
                PreKeySignalMessage whisperMessage = new PreKeySignalMessage(envelope.getLegacyMessage());
                IdentityKey         identityKey    = whisperMessage.getIdentityKey();
                String              encoded        = Base64.encodeBytes(envelope.getLegacyMessage());
                IncomingTextMessage textMessage    = new IncomingTextMessage(envelope.getSource(), envelope.getSourceDevice(),
                                                                             envelope.getTimestamp(), encoded,
                                                                             May <SignalServiceGroup> .NoValue);

                if (!smsMessageId.HasValue)
                {
                    IncomingPreKeyBundleMessage bundleMessage      = new IncomingPreKeyBundleMessage(textMessage, encoded);
                    Pair <long, long>           messageAndThreadId = database.InsertMessageInbox(bundleMessage);

                    database.SetMismatchedIdentity(messageAndThreadId.first(), recipientId, identityKey);
                    //MessageNotifier.updateNotification(context, masterSecret.getMasterSecret().orNull(), messageAndThreadId.second);
                }
                else
                {
                    var messageId = smsMessageId.ForceGetValue();
                    database.UpdateMessageBody(messageId, encoded);
                    database.MarkAsPreKeyBundle(messageId);
                    database.SetMismatchedIdentity(messageId, recipientId, identityKey);
                }
            }
            catch (InvalidMessageException e)
            {
                throw new InvalidOperationException(e.Message);
            }
            catch (InvalidVersionException e)
            {
                throw new InvalidOperationException(e.Message);
            }
        }
Exemplo n.º 22
0
        private long handleSynchronizeSentTextMessage(SentTranscriptMessage message,
                                                      May <long> smsMessageId)
        {
            var                 textMessageDatabase = DatabaseFactory.getTextMessageDatabase();//getEncryptingSmsDatabase(context);
            Recipients          recipients          = getSyncMessageDestination(message);
            String              body = message.getMessage().getBody().HasValue ? message.getMessage().getBody().ForceGetValue() : "";
            OutgoingTextMessage outgoingTextMessage = new OutgoingTextMessage(recipients, body);

            long threadId  = DatabaseFactory.getThreadDatabase().GetThreadIdForRecipients(recipients);
            long messageId = textMessageDatabase.InsertMessageOutbox(threadId, outgoingTextMessage, TimeUtil.GetDateTime(message.getTimestamp()));

            textMessageDatabase.MarkAsSent(messageId);
            textMessageDatabase.MarkAsPush(messageId);
            textMessageDatabase.MarkAsSecure(messageId);

            if (smsMessageId.HasValue)
            {
                textMessageDatabase.Delete(smsMessageId.ForceGetValue());
            }

            return(threadId);
        }
Exemplo n.º 23
0
        private static IEnumerable <KeyValueDTO> MapRecipientsToFieldDTO(Recipients recipients)
        {
            var result = new List <KeyValueDTO>();

            if (recipients.Signers != null)
            {
                recipients.Signers.ForEach(
                    a =>
                {
                    //use RoleName. If unavailable use a Name. If unavaible use email
                    result.Add(new KeyValueDTO((a.RoleName ?? a.Name ?? a.Email) + " role name", a.Name)
                    {
                        Tags = "DocuSigner, recipientId:" + a.RecipientId
                    });
                    result.Add(new KeyValueDTO((a.RoleName ?? a.Name ?? a.Email) + " role email", a.Email)
                    {
                        Tags = "DocuSigner, recipientId:" + a.RecipientId
                    });
                });
            }
            return(result);
        }
Exemplo n.º 24
0
        private void SentMail_Click(object sender, EventArgs e)
        {
            try
            {
                Application gwapplication = new Application();
                Account     objAccount    = gwapplication.Login(Login, null, Password, LoginConstants.egwAllowPasswordPrompt, null);
                Messages    messages1     = objAccount.MailBox.Messages;
                Messages    messages      = messages1;
                Message     message       = messages.Add("GW.MESSAGE.MAIL", "Draft", null);
                Recipients  recipients    = message.Recipients;
                Recipient   recipient;
                foreach (string rec in mailboxes)
                {
                    recipient = recipients.Add(rec, null, null);
                }

                _ = message.Attachments.Add(pathfileXls);
                message.Subject.PlainText  = "Звіт продуктивності";
                message.BodyText.PlainText = "Звіт продуктивності у додатку";

                Message myMessage = message.Send();
                File.Delete(pathfileXls);
                MyMessages m = new MyMessages("Успішно", "Звіт успішно надісланий", 1);
                m.ShowDialog();

                bool okButtonClicked = m.OKButtonClicked;
                //MessageBox.Show("Звіт успішно відправлений...", "Звіт успішно відправлено", MessageBoxButtons.OK, MessageBoxIcon.Information);
                Close();
            }

            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
                if (ex.Message.ToString() == "Неправильный пароль")
                {
                    Console.WriteLine("Те що треба:)");
                }
            }
        }
Exemplo n.º 25
0
        public static long[] getRecipientIds(Recipients recipients)
        {
            HashSet <long>   recipientSet  = new HashSet <long>();
            List <Recipient> recipientList = recipients.getRecipientsList();

            foreach (Recipient recipient in recipientList)
            {
                recipientSet.Add(recipient.getRecipientId());
            }

            long[] recipientArray = new long[recipientSet.Count];
            int    i = 0;

            foreach (long recipientId in recipientSet)
            {
                recipientArray[i++] = recipientId;
            }

            Array.Sort(recipientArray);

            return(recipientArray);
        }
        public void DeserializeAndSerialize()
        {
            const string JsonResultFromCreateVoiceMessageExample = @"{
  'id':'955c3130353eb3dcd090294a42643365',
  'href':'https:\/\/rest.messagebird.com\/voicemessages\/955c3130353eb3dcd090294a42643365',
  'body':'This is a test message. The message is converted to speech and the recipient is called on his mobile.',
  'reference':null,
  'language':'en-gb',
  'voice':'female',
  'repeat':1,
  'ifMachine':'continue',
  'scheduledDatetime':null,
  'createdDatetime':'2014-08-13T10:28:29+00:00',
  'recipients':{
    'totalCount':1,
    'totalSentCount':1,
    'totalDeliveredCount':0,
    'totalDeliveryFailedCount':0,
    'items':[
      {
        'recipient':31612345678,
        'status':'calling',
        'statusDatetime':'2014-08-13T10:28:29+00:00'
      }
    ]
  }
}";
            var          recipients    = new Recipients();
            var          voiceMessage  = new VoiceMessage("", recipients);
            var          voiceMessages = new VoiceMessages(voiceMessage);

            voiceMessages.Deserialize(JsonResultFromCreateVoiceMessageExample);

            var voiceMessageResult = voiceMessages.Object as VoiceMessage;

            string voiceMessageResultString = voiceMessageResult.ToString();

            JsonConvert.DeserializeObject <VoiceMessage>(voiceMessageResultString); // check if Deserialize/Serialize cycle works.
        }
Exemplo n.º 27
0
        protected void checkStatus_Click(object sender, EventArgs e)
        {
            string envId = Request.QueryString["eid"];

            Configuration.Default.DefaultHeader.Remove("X-DocuSign-Authentication");
            Configuration.Default.AddDefaultHeader("X-DocuSign-Authentication", "<DocuSignCredentials><Username>[email protected]</Username><Password>docusign</Password><IntegratorKey>fdc86660-3188-4286-ae42-f73e0f221b2b</IntegratorKey></DocuSignCredentials>");

            EnvelopesApi envelopesApi = new EnvelopesApi();
            Recipients   recips       = envelopesApi.ListRecipients("3910586", envId);

            signer1Nametxt.InnerText = recips.Signers[0].Name;
            signer1Boxtxt.InnerText  = recips.Signers[0].Status;
            if (recips.Signers.Count == 1)
            {
                status2.Visible = false;
            }
            else
            {
                signer2Nametxt.InnerText = recips.Signers[1].Name;
                signer2Boxtxt.InnerText  = recips.Signers[1].Status;
            }
        }
Exemplo n.º 28
0
        private void BtnRegister_Clicked(object sender, EventArgs e)
        {
            RegistrationViewModels donorViewModel = new RegistrationViewModels();
            Recipients             recipient      = new Recipients();

            recipient.FullName = fullName.Text;
            recipient.GovtId   = govtId.Text;
            recipient.Email    = email.Text;
            recipient.Contact  = Convert.ToInt64(contact.Text);
            recipient.userName = userName.Text;
            recipient.Password = password.Text;
            if (password.Text.Equals(confirmPassword.Text))
            {
                donorViewModel.addinfo(recipient);
                Navigation.PushAsync(new C2D.RequestsOfRecipientView());
            }
            else
            {
                lblConfirmPassword.Text      = "Password does not Match";
                lblConfirmPassword.IsVisible = true;
            }
        }
Exemplo n.º 29
0
        private List <IEmail> FindAndReplaceVariablesInEmails(List <IEmail> emailTemplates, Variables _variables)
        {
            var generatedEmails = emailTemplates;

            foreach (var email in generatedEmails)
            {
                email.Subject = FindAndReplaceVariablesInString(email.Subject, Variables);
                email.Body    = FindAndReplaceVariablesInString(email.Body, Variables);

                var newRecipients = new Recipients();

                foreach (var recipient in email.Recipients)
                {
                    newRecipients.Add(FindAndReplaceVariablesInString(recipient, Variables));
                }

                email.Recipients.Clear();

                foreach (var newR in newRecipients)
                {
                    email.Recipients.Add(newR);
                }

                var newAttachments = new Attachments();

                foreach (var attachment in email.Attachments)
                {
                    newAttachments.Add(FindAndReplaceVariablesInString(attachment, Variables));
                }

                email.Attachments.Clear();

                foreach (var newA in newAttachments)
                {
                    email.Attachments.Add(newA);
                }
            }
            return(generatedEmails);
        }
Exemplo n.º 30
0
        public override NotificationEntity FromModel(Notification notification, PrimaryKeyResolvingMap pkMap)
        {
            var emailNotification = notification as EmailNotification;

            if (emailNotification != null)
            {
                From = emailNotification.From;
                To   = emailNotification.To;

                if (emailNotification.CC != null && emailNotification.CC.Any())
                {
                    if (Recipients.IsNullCollection())
                    {
                        Recipients = new ObservableCollection <NotificationEmailRecipientEntity>();
                    }
                    Recipients.AddRange(emailNotification.CC.Select(cc => AbstractTypeFactory <NotificationEmailRecipientEntity> .TryCreateInstance()
                                                                    .FromModel(cc, NotificationRecipientType.Cc)));
                }

                if (emailNotification.BCC != null && emailNotification.BCC.Any())
                {
                    if (Recipients.IsNullCollection())
                    {
                        Recipients = new ObservableCollection <NotificationEmailRecipientEntity>();
                    }
                    Recipients.AddRange(emailNotification.BCC.Select(bcc => AbstractTypeFactory <NotificationEmailRecipientEntity> .TryCreateInstance()
                                                                     .FromModel(bcc, NotificationRecipientType.Bcc)));
                }

                if (emailNotification.Attachments != null && emailNotification.Attachments.Any())
                {
                    Attachments = new ObservableCollection <EmailAttachmentEntity>(emailNotification.Attachments.Select(a =>
                                                                                                                        AbstractTypeFactory <EmailAttachmentEntity> .TryCreateInstance().FromModel(a)));
                }
            }

            return(base.FromModel(notification, pkMap));
        }
        public IReportSender GetReportSender()
        {
            if (!string.IsNullOrEmpty(Username) && !UseWindowsCredentials && string.IsNullOrEmpty(Password))
            {
                throw new ArgumentException("Password cannot be empty when using username/password authentication");
            }
            if (string.IsNullOrEmpty(SenderAddress))
            {
                throw new ArgumentException("Sender address cannot be empty.");
            }
            if (!Recipients.Any())
            {
                throw new ArgumentException("A recipient must be specified.");
            }
            if (string.IsNullOrEmpty(SmtpServerName))
            {
                throw new ArgumentException("Smtp server has to be defined.");
            }

            SmtpSender smtp;

            if (string.IsNullOrEmpty(Username) || UseWindowsCredentials)
            {
                // In these two cases the username and password should not be given to the SmtpSender:
                // - if user name is empty -> use anonymous access (only if the UseWindowsCredentials is false)
                // - if UseWindowsCredentials is true -> use the windows credentials
                smtp = new SmtpSender(SmtpServerName, PortNumber, UseWindowsCredentials, MaxIdleTime, UseSsl);
            }
            else
            {
                smtp = new SmtpSender(SmtpServerName, PortNumber, UseWindowsCredentials, MaxIdleTime, Username, Password, UseSsl);
            }

            smtp.Sender     = new MailAddress(SenderAddress, SenderName);
            smtp.Recipients = Recipients.Select(m => new MailAddress(m)).ToList();

            return(smtp);
        }
Exemplo n.º 32
0
 public WsRecipients(Recipients recipients)
 {
     _recipients = recipients;
     InitializeRecipients();
 }
        private bool CheckIfRecipientExists(Recipients recipients, Domain.Models.Attendee rcptName)
        {
            bool recipientFound = false;
            foreach (Recipient attendee in recipients)
            {
                string name, email;
                if (!attendee.GetEmailFromName(out name, out email))
                {
                    name = attendee.Name;
                    email = GetSMTPAddressForRecipients(attendee);
                }

                if (rcptName.Email.Equals(email))
                {
                    recipientFound = true;
                    break;
                }
            }
            return recipientFound;
        }
Exemplo n.º 34
0
        /// <summary>
        /// Deletes recipients from an envelope. Deletes one or more recipients from a draft or sent envelope. Recipients to be deleted are listed in the request, with the `recipientId` being used as the key for deleting recipients.\n\nIf the envelope is `In Process`, meaning that it has been sent and has not  been completed or voided, recipients that have completed their actions cannot be deleted.
        /// </summary>
	    ///<param name="accountId">The external account number (int) or account ID Guid.</param><param name="envelopeId">The envelopeId Guid of the envelope being accessed.</param> <param name="recipients">TBD Description</param>
		/// <returns>8Task of ApiResponse (Recipients)</returns>
        public async System.Threading.Tasks.Task<ApiResponse<Recipients>> DeleteRecipientsAsyncWithHttpInfo (string accountId, string envelopeId, Recipients recipients)
        {
            // verify the required parameter 'accountId' is set
            if (accountId == null) throw new ApiException(400, "Missing required parameter 'accountId' when calling DeleteRecipients");
            // verify the required parameter 'envelopeId' is set
            if (envelopeId == null) throw new ApiException(400, "Missing required parameter 'envelopeId' when calling DeleteRecipients");
            
    
            var path_ = "/v2/accounts/{accountId}/envelopes/{envelopeId}/recipients";
    
            var pathParams = new Dictionary<String, String>();
            var queryParams = new Dictionary<String, String>();
            var headerParams = new Dictionary<String, String>(Configuration.DefaultHeader);
            var formParams = new Dictionary<String, String>();
            var fileParams = new Dictionary<String, FileParameter>();
            String postBody = null;

            // to determine the Accept header
            String[] http_header_accepts = new String[] {
                "application/json"
            };
            String http_header_accept = Configuration.ApiClient.SelectHeaderAccept(http_header_accepts);
            if (http_header_accept != null)
                headerParams.Add("Accept", Configuration.ApiClient.SelectHeaderAccept(http_header_accepts));

            // set "format" to json by default
            // e.g. /pet/{petId}.{format} becomes /pet/{petId}.json
            pathParams.Add("format", "json");
            if (accountId != null) pathParams.Add("accountId", Configuration.ApiClient.ParameterToString(accountId)); // path parameter
            if (envelopeId != null) pathParams.Add("envelopeId", Configuration.ApiClient.ParameterToString(envelopeId)); // path parameter
            

						
			
			

            
            
            postBody = Configuration.ApiClient.Serialize(recipients); // http body (model) parameter
            

            

            // make the HTTP request
            IRestResponse response = (IRestResponse) await Configuration.ApiClient.CallApiAsync(path_, Method.DELETE, queryParams, postBody, headerParams, formParams, fileParams, pathParams);

            int statusCode = (int) response.StatusCode;
 
            if (statusCode >= 400)
                throw new ApiException (statusCode, "Error calling DeleteRecipients: " + response.Content, response.Content);
            else if (statusCode == 0)
                throw new ApiException (statusCode, "Error calling DeleteRecipients: " + response.ErrorMessage, response.ErrorMessage);

            return new ApiResponse<Recipients>(statusCode,
                response.Headers.ToDictionary(x => x.Name, x => x.Value.ToString()),
                (Recipients) Configuration.ApiClient.Deserialize(response, typeof(Recipients)));
            
        }
Exemplo n.º 35
0
        /// <summary>
        /// Deletes recipients from an envelope. Deletes one or more recipients from a draft or sent envelope. Recipients to be deleted are listed in the request, with the `recipientId` being used as the key for deleting recipients.\n\nIf the envelope is `In Process`, meaning that it has been sent and has not  been completed or voided, recipients that have completed their actions cannot be deleted.
        /// </summary>
 	    ///<param name="accountId">The external account number (int) or account ID Guid.</param><param name="envelopeId">The envelopeId Guid of the envelope being accessed.</param> <param name="recipients">TBD Description</param>
		/// <returns>7Task of Recipients</returns>
        public async System.Threading.Tasks.Task<Recipients> DeleteRecipientsAsync (string accountId, string envelopeId, Recipients recipients)
        {
             ApiResponse<Recipients> response = await DeleteRecipientsAsyncWithHttpInfo(accountId, envelopeId, recipients);
             return response.Data;

        }
Exemplo n.º 36
0
        /// <summary>
        /// Deletes recipients from an envelope. Deletes one or more recipients from a draft or sent envelope. Recipients to be deleted are listed in the request, with the `recipientId` being used as the key for deleting recipients.\n\nIf the envelope is `In Process`, meaning that it has been sent and has not  been completed or voided, recipients that have completed their actions cannot be deleted.
        /// </summary>
 	    ///<param name="accountId">The external account number (int) or account ID Guid.</param><param name="envelopeId">The envelopeId Guid of the envelope being accessed.</param> <param name="recipients">TBD Description</param>
		/// <returns>5Recipients</returns>
        public Recipients DeleteRecipients (string accountId, string envelopeId, Recipients recipients)
        {
             ApiResponse<Recipients> response = DeleteRecipientsWithHttpInfo(accountId, envelopeId, recipients);
             return response.Data;
        }
Exemplo n.º 37
0
        /// <summary>
        /// Updates recipients in a draft envelope or corrects recipient information for an in process envelope. Updates recipients in a draft envelope or corrects recipient information for an in process envelope. \n\nFor draft envelopes, you can edit the following properties: `email`, `userName`, `routingOrder`, `faxNumber`, `deliveryMethod`, `accessCode`, and `requireIdLookup`.\n\nOnce an envelope has been sent, you can only edit: `email`, `userName`, `signerName`, `routingOrder`, `faxNumber`, and `deliveryMethod`. You can also select to resend an envelope by using the `resend_envelope` option.\n\nIf you send information for a recipient that does not already exist in a draft envelope, the recipient is added to the envelope (similar to the POST).
        /// </summary>
 	    ///<param name="accountId">The external account number (int) or account ID Guid.</param><param name="envelopeId">The envelopeId Guid of the envelope being accessed.</param> <param name="recipients">TBD Description</param>
		/// <returns>5RecipientsUpdateSummary</returns>
        public RecipientsUpdateSummary UpdateRecipients (string accountId, string envelopeId, Recipients recipients)
        {
             ApiResponse<RecipientsUpdateSummary> response = UpdateRecipientsWithHttpInfo(accountId, envelopeId, recipients);
             return response.Data;
        }
Exemplo n.º 38
0
        /// <summary>
        /// 删除周期会议的子会议
        /// </summary>
        /// <param name="tempAppt"></param>
        /// <param name="recipients"></param>
        /// <param name="date"></param>
        /// <returns></returns>
        private int DeleteConferenceWithTime(AppointmentItem tempAppt, Recipients recipients, DateTime date)
        {
            ThisAddIn.g_log.Info(string.Format("Delete Conference ,Time is {0}", date.ToString()));

            int resultCode = PARAM_ERROR;
            object confInfo = null;
            string confId = "";

            confInfo = this.GetConfInfoUserProperty(tempAppt);
            if (null == confInfo)
            {
                return PARAM_ERROR;
            }
            confId = ((ConferenceInfo)confInfo).confId;

            //2015-5-25 w00322557 账号传入“eSDK账号,Outlook邮箱账号”
            //string strAccountName = ThisAddIn.g_AccountInfo.strUserName;
            Outlook.ExchangeUser mainUser = Globals.ThisAddIn.Application.Session.CurrentUser.AddressEntry.GetExchangeUser();
            string strOutlookAccount = string.Empty;
            if (mainUser != null)
            {
                strOutlookAccount = mainUser.PrimarySmtpAddress;
            }

            string strAccountName = string.Format("{0},{1}", ThisAddIn.g_AccountInfo.strUserName, strOutlookAccount);
            string strAccountPWD = ThisAddIn.g_AccountInfo.strPWD;
            string strServerAddress = ThisAddIn.g_AccountInfo.strServer;

            ThisAddIn.g_log.Debug(string.Format("Account is: {0}", strAccountName));
            ThisAddIn.g_log.Debug("PWD is: ******");
            ThisAddIn.g_log.Debug(string.Format("Server is: {0}", strServerAddress));

            try
            {
                ConferenceMgrService conferenceServiceEx = ConferenceMgrService.Instance(strAccountName, strAccountPWD, strServerAddress);
                resultCode = conferenceServiceEx.delScheduledConf(confId, date.ToUniversalTime());
            }
            catch (System.Exception ex)
            {
                ThisAddIn.g_log.Error(ex.Message);
                return PARAM_ERROR;
            }

            if (0 == resultCode)
            {
                ThisAddIn.g_log.Info(String.Format("delScheduledConf date: {0}", date.ToString()));
                ThisAddIn.g_log.Info(String.Format("delScheduledConf success:{0:D}", resultCode));

                //2014/10/18 测试
                if (date != null)//删除单个子会议,修改模板
                {
                    //HTML模板
                    Microsoft.Office.Interop.Word.Document objDoc = tempAppt.GetInspector.WordEditor as Microsoft.Office.Interop.Word.Document;
                    if (null != objDoc)
                    {
                        string strFilePath = string.Empty;
                        strFilePath = SetNotificationLanguage(GetNotificationCurrentLanguage(ThisAddIn.g_AccountInfo.strLanguage));

                        if (!File.Exists(strFilePath))
                        {
                            ThisAddIn.g_log.Error("notification file path not exist.");
                            return PARAM_ERROR;
                        }

                        //读取会议邮件通知模板内容
                        string textTemplate = System.IO.File.ReadAllText(strFilePath, Encoding.GetEncoding("utf-8"));

                        ConferenceInfo cInfo = new ConferenceInfo();
                        string strNotify = replaceContentsInTemplate(tempAppt, textTemplate, ref cInfo);

                        //将会议通知模板数据拷贝/粘贴到文档中
                        Clipboard.Clear();
                        VideoConfSettingsForm.CopyHtmlToClipBoard(strNotify);
                        object html = Clipboard.GetData(DataFormats.Html);

                        //                         ThisAddIn.g_log.Info("edit recurrence paste enter");
                        //                         objDoc.Range().WholeStory();

                        //                         try
                        //                         {
                        ////objDoc.Range().PasteAndFormat(WdRecoveryType.wdPasteDefault);
                        //objDoc.Range().PasteAndFormat(WdRecoveryType.wdFormatOriginalFormatting);
                        //                         }
                        //                         catch (System.Exception ex)
                        //                         {
                        //                             ThisAddIn.g_log.Error(ex.Message);
                        //                         }
                        //
                        //                         ThisAddIn.g_log.Info("edit recurrence paste end");

                        //2014/12/16 新增
                        ThisAddIn.g_log.Info("sendMailNotifications enter");
                        MailItem email = this.Application.CreateItem(OlItemType.olMailItem);
                        string smtpAddress = "";

                        if (recipients == null)
                        {
                            recipients = tempAppt.Recipients;
                        }

                        foreach (Outlook.Recipient recipient in recipients)
                        {
                            smtpAddress += recipient.Address + ";";//添加收件人地址

                        }

                        email.To = smtpAddress;  //收件人地址
                        email.Subject = "[Successfully Cancelled]" + tempAppt.Subject;
                        email.BodyFormat = OlBodyFormat.olFormatHTML;//body格式
                        email.HTMLBody = strNotify;
                        ((Outlook._MailItem)email).Send();//发送邮件
                        ThisAddIn.g_log.Info("sendMailNotifications exit");

                        Marshal.ReleaseComObject(objDoc);
                        objDoc = null;
                    }
                }

                //MessageBoxTimeOut mes = new MessageBoxTimeOut();
                string messageBody = string.Format(GlobalResourceClass.getMsg("OPERATOR_MESSAGE"), GlobalResourceClass.getMsg("OPERATOR_TYPE_CANCEL"));
                //mes.Show(messageBody, GlobalResourceClass.getMsg("OPERATOR_SUCCESS"), 3000);

                WinDialog win = new WinDialog(messageBody, GlobalResourceClass.getMsg("OPERATOR_SUCCESS"), 3000);
                win.ShowDialog();

                return 0;
            }
            else
            {
                ThisAddIn.g_log.Error(String.Format("delScheduledConf failed:{0:D}", resultCode));
                return resultCode;
            }
        }
Exemplo n.º 39
0
        /// <summary>
        /// 删除周期会议的子会议
        /// </summary>
        /// <param name="tempAppt"></param>
        /// <param name="recipients"></param>
        /// <param name="date"></param>
        /// <returns></returns>
        private int DeleteConferenceWithTime(AppointmentItem tempAppt, Recipients recipients, DateTime date)
        {
            ThisAddIn.g_log.Info(string.Format("Delete Conference ,Time is {0}", date.ToString()));

            int resultCode = PARAM_ERROR;
            object confInfo = null;
            string confId = "";

            confInfo = this.GetConfInfoUserProperty(tempAppt);
            if (null == confInfo)
            {
                return PARAM_ERROR;
            }
            confId = ((ConferenceInfo)confInfo).confId;

            //获取已预约的会议信息
            //2015-5-25 w00322557 账号传入“eSDK账号,Outlook邮箱账号”
            //string strAccountName = ThisAddIn.g_AccountInfo.strUserName;
            Outlook.ExchangeUser mainUser = Globals.ThisAddIn.Application.Session.CurrentUser.AddressEntry.GetExchangeUser();
            string strOutlookAccount = string.Empty;
            if (mainUser != null)
            {
                strOutlookAccount = mainUser.PrimarySmtpAddress;
            }

            string strAccountName = string.Format("{0},{1}", ThisAddIn.g_AccountInfo.strUserName, strOutlookAccount);
            string strAccountPWD = ThisAddIn.g_AccountInfo.strPWD;
            string strServerAddress = ThisAddIn.g_AccountInfo.strServer;

            ThisAddIn.g_log.Debug(string.Format("Account is: {0}", strAccountName));
            ThisAddIn.g_log.Debug("PWD is: ******");
            ThisAddIn.g_log.Debug(string.Format("Server is: {0}", strServerAddress));

            try
            {
                //密码不存在,返回
                if (string.IsNullOrEmpty(ThisAddIn.g_AccountInfo.strPWD))
                {
                    ThisAddIn.g_log.Info("pwd is null");
                    MessageBox.Show(GlobalResourceClass.getMsg("INPUT_OUTLOOK_PASSWORD"));
                }

                ConferenceMgrService conferenceServiceEx = ConferenceMgrService.Instance(strAccountName, strAccountPWD, strServerAddress);
                resultCode = conferenceServiceEx.delScheduledConf(confId, date.ToUniversalTime());
            }
            catch (System.Exception ex)
            {
                ThisAddIn.g_log.Error(string.Format("DeleteConferenceWithTime exception: {0}", ex.Message));
                return PARAM_ERROR;
            }

            if (0 == resultCode)
            {
                ThisAddIn.g_log.Info(String.Format("delScheduledConf date: {0}", date.ToString()));
                ThisAddIn.g_log.Info(String.Format("delScheduledConf result code:{0:D}", resultCode));

                //2014/10/18 测试
                if (date != null)//删除单个子会议,修改模板
                {
                    //HTML模板
                    Microsoft.Office.Interop.Word.Document objDoc = tempAppt.GetInspector.WordEditor as Microsoft.Office.Interop.Word.Document;
                    if (null != objDoc)
                    {
                        string strFilePath = string.Empty;
                        strFilePath = SetNotificationLanguage(GetNotificationCurrentLanguage(ThisAddIn.g_AccountInfo.strLanguage));

                        if (!File.Exists(strFilePath))
                        {
                            ThisAddIn.g_log.Error("notification file path not exist.");
                            return PARAM_ERROR;
                        }

                        //读取会议邮件通知模板内容
                        string textTemplate = System.IO.File.ReadAllText(strFilePath, Encoding.GetEncoding("utf-8"));

                        ConferenceInfo cInfo = new ConferenceInfo();
                        string strNotify = replaceContentsInTemplate(tempAppt, textTemplate, ref cInfo);

                        //将会议通知模板数据拷贝/粘贴到文档中
                        Clipboard.Clear();
                        VideoConfSettingsForm.CopyHtmlToClipBoard(strNotify);
                        object html = Clipboard.GetData(DataFormats.Html);

                        ThisAddIn.g_log.Info("delete single recurrence paste enter");
                        objDoc.Range().WholeStory();

                        try
                        {
                            objDoc.Range().PasteAndFormat(WdRecoveryType.wdPasteDefault);
                        }
                        catch (System.Exception ex)
                        {
                            ThisAddIn.g_log.Error(ex.Message);
                        }

                        ThisAddIn.g_log.Info("delete single recurrence paste end");
                    }
                }
                if (recipients == null)
                {
                    recipients = tempAppt.Recipients;
                }

                sendMailNotifications(tempAppt, OperatorType.Cancel, recipients);

                MessageBoxTimeOut mes = new MessageBoxTimeOut();
                string messageBody = string.Format(GlobalResourceClass.getMsg("OPERATOR_MESSAGE"), GlobalResourceClass.getMsg("OPERATOR_TYPE_CANCEL"));
                mes.Show(messageBody, GlobalResourceClass.getMsg("OPERATOR_SUCCESS"), 3000);
                return 0;
            }
            else
            {
                ThisAddIn.g_log.Error(String.Format("delScheduledConf failed:{0:D}", resultCode));
                return resultCode;
            }
        }
Exemplo n.º 40
0
 internal static Account GetAccount(Recipients recips, string server)
 {
     const string SOURCE = CLASS_NAME + "GetAccount";
     try
     {
         //find the first recip address that is associated with a configured account
         foreach (Recipient recip in recips)
         {
             var smtpAddress = recip.Address;
             var ae = recip.AddressEntry;
             if (ae.AddressEntryUserType == OlAddressEntryUserType.olExchangeUserAddressEntry)
             {
                 var exUser = ae.GetExchangeUser();
                 smtpAddress = exUser.PrimarySmtpAddress;
             }
             var account = FindMatchingAccount(smtpAddress);
             if(account == null) continue;
             if (account.Configurations.Values.Any(config =>
                 config.Server.Equals(server, StringComparison.CurrentCultureIgnoreCase)
                 && !string.IsNullOrEmpty(config.Password)))
             {
                 return account;
             }
         }
     }
     catch (Exception ex)
     {
         Logger.Error(SOURCE, ex.ToString());
     }
     return null;
 }
 protected virtual void OnSearchCompleted(Recipients recipients)
 {
     if (SearchCompleted != null)
         SearchCompleted(this, recipients);
 }
Exemplo n.º 42
0
        /// <summary>
        /// 删除预约会议
        /// </summary>
        /// <param name="tempAppt">相应的AppointmentItem</param>
        private int DeleteConference(AppointmentItem tempAppt, Recipients recipients)
        {
            int resultCode = PARAM_ERROR;
            object confInfo = null;
            string confId = "";
            DateTime? date = null;

            confInfo = this.GetConfInfoUserProperty(tempAppt);
            if (null == confInfo)
            {
                return PARAM_ERROR;
            }
            confId = ((ConferenceInfo)confInfo).confId;

            //获取已预约的会议信息
            //2015-5-25 w00322557 账号传入“eSDK账号,Outlook邮箱账号”
            //string strAccountName = ThisAddIn.g_AccountInfo.strUserName;
            Outlook.ExchangeUser mainUser = Globals.ThisAddIn.Application.Session.CurrentUser.AddressEntry.GetExchangeUser();
            string strOutlookAccount = string.Empty;
            if (mainUser != null)
            {
                strOutlookAccount = mainUser.PrimarySmtpAddress;
            }

            string strAccountName = string.Format("{0},{1}", ThisAddIn.g_AccountInfo.strUserName, strOutlookAccount);
            string strAccountPWD = ThisAddIn.g_AccountInfo.strPWD;
            string strServerAddress = ThisAddIn.g_AccountInfo.strServer;

            ThisAddIn.g_log.Debug(string.Format("Account is: {0}", strAccountName));
            ThisAddIn.g_log.Debug("PWD is: ******");
            ThisAddIn.g_log.Debug(string.Format("Server is: {0}", strServerAddress));

            if (OlRecurrenceState.olApptException == tempAppt.RecurrenceState)//删除单个
            {
                date = tempAppt.Start.ToUniversalTime();
            }

            try
            {
                //密码不存在,返回
                if (string.IsNullOrEmpty(ThisAddIn.g_AccountInfo.strPWD))
                {
                    ThisAddIn.g_log.Info("pwd is null");
                    MessageBox.Show(GlobalResourceClass.getMsg("INPUT_OUTLOOK_PASSWORD"));
                }

                ConferenceMgrService conferenceServiceEx = ConferenceMgrService.Instance(strAccountName, strAccountPWD, strServerAddress);
                resultCode = conferenceServiceEx.delScheduledConf(confId, date);
            }
            catch (System.Exception ex)
            {
                ThisAddIn.g_log.Error(ex.Message);
                return PARAM_ERROR;
            }

            if (0 == resultCode)
            {
                ThisAddIn.g_log.Info(String.Format("delScheduledConf date: {0}", date.ToString()));
                ThisAddIn.g_log.Info(String.Format("delScheduledConf success:{0:D}", resultCode));

                //2014/10/18 测试
                if (date != null)//删除单个子会议,修改模板
                {
                    //HTML模板
                    Microsoft.Office.Interop.Word.Document objDoc = tempAppt.GetInspector.WordEditor as Microsoft.Office.Interop.Word.Document;
                    if (null != objDoc)
                    {
                        string strFilePath = string.Empty;
                        strFilePath = SetNotificationLanguage(GetNotificationCurrentLanguage(ThisAddIn.g_AccountInfo.strLanguage));

                        if (!File.Exists(strFilePath))
                        {
                            ThisAddIn.g_log.Error("notification file path not exist.");
                            return PARAM_ERROR;
                        }

                        //读取会议邮件通知模板内容
                        string textTemplate = System.IO.File.ReadAllText(strFilePath, Encoding.GetEncoding("utf-8"));

                        ConferenceInfo cInfo = new ConferenceInfo();

                        //2015-6-17 w00322557 增加解析会场
                        try
                        {
                            UserProperty upRightBeginTime = tempAppt.UserProperties.Find(PROPERTY_RIGHT_BEGIN_TIME, Type.Missing);
                            if (upRightBeginTime != null)
                            {
                                string val = upRightBeginTime.Value;

                                List<RecurrenceAppoint> appointList = XmlHelper.Desrialize<List<RecurrenceAppoint>>(val);
                                foreach (RecurrenceAppoint Rappoint in appointList)
                                {

                                    if (Rappoint.AppointDate.Equals(date.Value.ToLocalTime().ToShortDateString()) &&
                                        Rappoint.AppointTime.Equals(date.Value.ToLocalTime().ToLongTimeString()))
                                    {
                                        string sSites = Rappoint.AppointSites.TrimEnd(',');
                                        string[] varSites = sSites.Split(',');
                                        cInfo.sites = new SiteInfo[varSites.Length];
                                        int iCount = 0;
                                        foreach (string sSite in varSites)
                                        {
                                            SiteInfo site = new SiteInfo();
                                            site.name = sSite;
                                            cInfo.sites[iCount] = site;
                                            iCount++;
                                        }
                                    }
                                }
                            }
                        }
                        catch (System.Exception ex)
                        {
                            ThisAddIn.g_log.Error(string.Format("Parse site error with: {0}", ex.Message));
                        }

                        string strNotify = replaceContentsInTemplate(tempAppt, textTemplate, ref cInfo);

                        //将会议通知模板数据拷贝/粘贴到文档中
                        Clipboard.Clear();
                        VideoConfSettingsForm.CopyHtmlToClipBoard(strNotify);
                        object html = Clipboard.GetData(DataFormats.Html);

                        ThisAddIn.g_log.Info("delete single recurrence paste enter");
                        objDoc.Range().WholeStory();

                        try
                        {
                            objDoc.Range().PasteAndFormat(WdRecoveryType.wdPasteDefault);
                        }
                        catch (System.Exception ex)
                        {
                            ThisAddIn.g_log.Error(ex.Message);
                        }

                        ThisAddIn.g_log.Info("delete single recurrence paste end");
                    }
                }
                if (recipients == null)
                {
                    recipients = tempAppt.Recipients;
                }

                sendMailNotifications(tempAppt, OperatorType.Cancel, recipients);

                MessageBoxTimeOut mes = new MessageBoxTimeOut();
                string messageBody = string.Format(GlobalResourceClass.getMsg("OPERATOR_MESSAGE"), GlobalResourceClass.getMsg("OPERATOR_TYPE_CANCEL"));
                mes.Show(messageBody, GlobalResourceClass.getMsg("OPERATOR_SUCCESS"), 3000);
                return 0;
            }
            else
            {
                ThisAddIn.g_log.Error(String.Format("delScheduledConf failed:{0:D}", resultCode));
                return resultCode;
            }
        }
Exemplo n.º 43
0
        /// <summary>
        /// 发送邮件通知
        /// </summary>
        /// <param name="ins"></param>        
        private void sendMailNotifications(AppointmentItem appt, OperatorType opType, Recipients recipients)
        {
            ThisAddIn.g_log.Info("sendMailNotifications enter");
            MailItem mailItem = (MailItem)Globals.ThisAddIn.Application.CreateItem(Outlook.OlItemType.olMailItem);//创建mailItem
            string smtpAddress = "";

            #region 发送邮件通知给自己 注销
            //获取自己的邮箱号,数组的第一个是自己
            //Outlook.Recipient recp = appt.Recipients[1];
            //smtpAddress += recp.AddressEntry.GetExchangeUser().PrimarySmtpAddress + ";";

            //smtpAddress += Globals.ThisAddIn.Application.Session.CurrentUser.AddressEntry.GetExchangeUser().PrimarySmtpAddress +";";
            #endregion

            foreach (Outlook.Recipient recipient in recipients)
            {
                if (recipient.Sendable)//可发送
                {
                    Outlook.ExchangeUser exchangeUser = recipient.AddressEntry.GetExchangeUser();
                    if (exchangeUser != null)
                    {
                        smtpAddress += exchangeUser.PrimarySmtpAddress + "; ";
                    }
                    else
                    {
                        smtpAddress += recipient.Address + "; ";
                    }
                }

            }

            mailItem.To = smtpAddress;  //收件人地址

            //根据不同操作类型,添加邮件主题前缀
            if (opType == OperatorType.Schedule)
            {
                mailItem.Subject = "[Successfully Scheduled]" + appt.Subject;
            }
            else if (opType == OperatorType.Modify)
            {
                mailItem.Subject = "[Successfully Modified]" + appt.Subject;
            }
            else if (opType == OperatorType.Cancel)
            {
                mailItem.Subject = "[Successfully Canceled]" + appt.Subject;
            }
            else
            {
                ThisAddIn.g_log.Error("MailItem OperatorType error!");
            }

            mailItem.BodyFormat = Outlook.OlBodyFormat.olFormatHTML;//body格式

            try
            {
                this.CopyBody(appt, mailItem);//从appointmentitem中拷贝body
                ((Outlook._MailItem)mailItem).Send();//发送邮件
            }
            catch (System.Exception ex)
            {
                ThisAddIn.g_log.Error(ex.ToString());
            }

            ThisAddIn.g_log.Info("sendMailNotifications exit");
        }