Example #1
0
        private static Microsoft.Graph.Message CreateMessage()
        {
            var mailboxHelper = new MailboxHelper(_graphServiceClient);

            var message = new Microsoft.Graph.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);
        }
Example #2
0
        // Send Message
        private static Microsoft.Graph.Message SendMessage(Microsoft.Graph.Message message)
        {
            var mailboxHelper = new MailboxHelper(_graphServiceClient);

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

            return(message);
        }
Example #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);
        }
Example #4
0
        // Create upload session
        private static UploadSession CreateUploadSession(Microsoft.Graph.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);
        }