Beispiel #1
0
        public async Task <string> SendMI4DEmail(MyEmails email)
        {
            SendGridClient client = new SendGridClient(_connectionStrings.Value.SendGrid);

            var msg = new SendGridMessage();

            msg.SetFrom(new EmailAddress("*****@*****.**", "Suporte MI3D Plus"));
            msg.SetSubject(email.Subject);
            msg.AddContent(MimeType.Html, email.Body);
            msg.AddTo(new EmailAddress(email.To.First().Address, email.To.First().DisplayName));

            if (email.To.First().Address != "*****@*****.**")
            {
                msg.AddCc(new EmailAddress("*****@*****.**", "Carlos de Souza"));
            }

            if (email.To.First().Address != "*****@*****.**")
            {
                msg.AddCc(new EmailAddress("*****@*****.**", "Ricardo Gaefke"));
            }

            var response = await client.SendEmailAsync(msg);

            return(response.Headers.GetValues("x-message-id").FirstOrDefault());
        }
Beispiel #2
0
        public async Task EnviarEmailsMI4D(
            [QueueTrigger("%queueName_mi4d%")]
            string message,
            int DequeueCount,
            ILogger logger
            )
        {
            MyEmails email = JsonConvert.DeserializeObject <MyEmails>(message);

            string SgId = await _email.SendMI4DEmail(email);

            _emailMI4D.SaveEmailData(SgId, email.To.First().Address, DequeueCount);

            await _connection.InvokeAsync("MI4D", SgId);
        }
Beispiel #3
0
        public async Task <Response> Handle(Request message)
        {
            var linkedFolder = await this.context.LinkedFolders
                               .Include(t => t.Inbox)
                               .SingleOrExceptionAsync(t => t.Id == message.LinkedFolderId);

            var emailCount = await this.context.ImportedEmails.CountAsync(t => t.LinkedFolderId == message.LinkedFolderId);

            return(new Response
            {
                Tabs = TabstripUtility.GetLinkedFolderTabs(typeof(LinkedFolderOverview).GetFormId(), linkedFolder.Id),
                Inbox = InboxOverview.Button(linkedFolder.InboxId, linkedFolder.Inbox.Name),
                NewItemsFolder = linkedFolder.NewItemsFolder,
                ProcessedItemsFolder = linkedFolder.ProcessedItemsFolder,
                EmailCount = MyEmails.Button(emailCount.ToString(), linkedFolder.Id),
                Actions = new ActionList(EditLinkedFolder.Button(linkedFolder.Id), ImportEmails.Button(linkedFolder.Id, "Import emails")),
                Metadata = new MyFormResponseMetadata
                {
                    Title = linkedFolder.Name
                }
            });
        }
Beispiel #4
0
        public async Task <Response> Handle(Request message)
        {
            var inbox = await this.context.Inboxes
                        .Include(t => t.LinkedFolders)
                        .SingleOrExceptionAsync(t => t.Id == message.InboxId);

            var folderIds   = inbox.LinkedFolders.Select(t => t.Id).ToList();
            var emailCounts = await this.context.ImportedEmails
                              .Where(t => folderIds.Contains(t.LinkedFolderId))
                              .GroupBy(t => t.LinkedFolderId)
                              .Select(t => new
            {
                LinkedFolderId = t.Key,
                EmailCount     = t.Count()
            })
                              .ToDictionaryAsync(t => t.LinkedFolderId);

            return(new Response
            {
                Folders = inbox.LinkedFolders.Select(t => new LinkedFolderRow
                {
                    ProcessedItemsFolder = t.ProcessedItemsFolder,
                    NewItemsFolder = t.NewItemsFolder,
                    EmailCount = MyEmails.Button((emailCounts.GetValueOrDefault(t.Id)?.EmailCount ?? 0).ToString(), t.InboxId),
                    Actions = new ActionList(
                        RemoveLinkedFolder.Button(t.Id),
                        ImportEmails.Button(t.Id, "Import emails"))
                }).ToList(),
                Actions = new ActionList(AddLinkedFolder.Button(inbox.Id, "Add new linked folder")),
                Tabs = TabstripUtility.GetInboxTabs(typeof(LinkedFolders).GetFormId(), inbox.Id),
                Metadata = new MyFormResponseMetadata
                {
                    Title = inbox.Email
                }
            });
        }