Ejemplo n.º 1
0
        // Create message
        private static Message CreateMessage()
        {
            var mailboxHelper = new MailboxHelper(_graphServiceClient);

            var message = new Message
            {
                Subject    = "Large attachment is here",
                Importance = Importance.Low,
                Body       = new ItemBody
                {
                    ContentType = BodyType.Html,
                    Content     = "Why can't you make small <b>attachments</b>!"
                },
                ToRecipients = new List <Recipient>()
                {
                    new Recipient
                    {
                        EmailAddress = new EmailAddress
                        {
                            Address = "*****@*****.**"
                        }
                    }
                }
            };

            message = mailboxHelper.CreateMessage(message, userId).Result;
            Console.WriteLine("Message Id: " + message.Id);

            return(message);
        }
Ejemplo n.º 2
0
        // Send Message
        private static Message SendMessage(Message message)
        {
            var mailboxHelper = new MailboxHelper(_graphServiceClient);

            mailboxHelper.SendMessage(message, userId);
            Console.WriteLine("Message sent");

            return(message);
        }
Ejemplo n.º 3
0
        // Upload attachment
        private static UploadResult <AttachmentItem> UploadAttachment(UploadSession uploadSession, FileStream attachmentStream)
        {
            var mailboxHelper = new MailboxHelper(_httpClient);

            var uploadResult = mailboxHelper.UploadAttachment(uploadSession, attachmentStream).Result;

            Console.WriteLine("Upload Succeeded: " + uploadResult.UploadSucceeded);

            return(uploadResult);
        }
Ejemplo n.º 4
0
        // Create upload session
        private static UploadSession CreateUploadSession(Message message, string attachmentName, long attachmentSize)
        {
            var mailboxHelper = new MailboxHelper(_graphServiceClient);

            var attachmentItem = new AttachmentItem()
            {
                AttachmentType = AttachmentType.File,
                Name           = attachmentName,
                Size           = attachmentSize
            };

            var uploadSession = mailboxHelper.CreateUploadSession(message, userId, attachmentItem).Result;

            Console.WriteLine("Upload URL: " + uploadSession.UploadUrl);

            return(uploadSession);
        }