Get Server URL of an Email Attachment using Exchange Web Services - c#

I'm developing an app that deals with emails. What I need is to get the URL of the location the attachment is stored on the exchange server. I can't download the attachment to my local machine so the attachment has to be accessed on the exchange server.
Is this possible?
I have looked online but can't seem to find anything.

With EWS no there is no URL to download an Attachment directly you need to know the AttachmentId (generally you would get this by using the GetItem operation) then you can use the GetAttachment operation to get the contents of the attachment (which is a Base64 Stream). see https://learn.microsoft.com/en-us/exchange/client-developer/web-service-reference/getattachment-operation

Related

How do I download the email I just sent using Graph API?

I am using GraphAPI for sending email. I have a situation where I need to Save a copy of the email sent. I can retrieve the Messages using graph api. How do I identify the email I just sent? When I use the SendEmail endpoint of the Graph api, I get a 200 OK response. How do I identify the email I just sent so I can download that email?
I have tried a number of solutions, adding custom Identifiers and filtering it but none of them worked.
I haven't tried this, but this approach seems it would work: https://learn.microsoft.com/en-us/graph/outlook-immutable-id#immutable-id-with-sending-mail.
Create the message as a draft with Prefer: IdType="ImmutableId" header
Save the returned id
Send the draft
Note that email sending is asynchronous so you might not be able to download the sent email right away. It could take some time to be available.

Craft/Construct attachment using MailKit

I could not find this question anywhere.
Is it possible to craft attachment using MailKit without saving it local?
I have application linked to database and I am making Windows service for sending emails.
I read data from DB and I would like to craft .json attachment inside program and send it via mail using MailKit without saving that attachment local.
Thanks in advance.
MimeKit allows reading from and writing to MemoryStreams (and other non-File-based streams).
You can also construct messages where the content of attachments and such are stored only in memory and not on disk.
The BodyBuilder.Attachments collection allows adding attachment data as byte[] and Streams (which includes allowing MemoryStreams). The fileName parameters in these Add() methods is only to provide a file name to set on the attachment.

Show only attachment link in mailkit imap

I just want to display the links of attachments to download in mail body without downloading the attachment initially. coz i don't want to download and save the attachments on my server everytime.
when users clicks the link, then I want to download that particular attachment(s) from gmail server ("https://mail-attachment.googleusercontent.com/attachment/u/1/?xxxx-xxxx")
is there is anyway to do this?
MailKit does not provide any way of doing this because it's not something that IMAP supports.
That said, it might be possible to figure out how to construct the URL based on the properties of the MIME attachment.
Based on examining the Download link in one of my own emails, it looks like Google uses their X-Attachment-Id header value to construct the realattid portion of the url. They probably have other variables as well, but it's hard to know exactly where the other values come from.
The attid value in the download url appears to be a positional value of the MIME attachment in the tree, similar to MailKit's BodyPart.PartSpecifier string.
Instead of trying to recreate GMail's download link, you could always use MailKit's ImapFolder.GetBodyPart() API to download individual MIME parts when the user requests them.
In order to take advantage of this API, you'll need to call ImapFolder.Fetch() with MessageSummaryItems.BodyStructure.
You can take a look at https://github.com/jstedfast/MailKit/blob/master/samples/ImapClientDemo/ImapClientDemo/MainWindow.cs to see how to use the MessageSummary.Bodyproperty that you get back from the Fetch request.

Add PDF attachment to BizTalk email service

I have come into ownership of a ASP.NET MVC site that utilizes Biztalk 2013 to handle tasks like sending emails. I am completely new to biztalk so forgive obvious mistakes in this post.
Quick overview
The service is called through the application and then the orchestration calls a stored procedure in a sql db to populate some of values for the email (including html for the email) and then sends the email out.
I now want to add a pdf attachment to the email.
As a test, I added a pdf file to the server and then I have tried adding ActualEmailMsg(SMTP.Attachments) = "C:\\PDFs\\test.pdf";
ActualEmailMsg(SMTP.MessagePartsAttachments) = 2; to the message assignment expression shape as suggested in this post to no avail. (I also tried the physical path with only 1 "\" like "C:\\PDFs\test.pdf" and that didn't work)
I have ruled out the possibility of a lack of permissions from the service account to the PDF folder. The email sends correctly but no attachment is present. I am getting no errors in the code or in the event viewer on the server so at this point I am at a loss for what it might be.
After lots of googling I found the issue was related to the send pipeline. This thread got me on the right track.
In the send ports section of the BizTalk Admin Console of the app, the send pipeline was using a custom pipeline I believe was made by the previous owner. I changed it to the 'Pass Thru Transmit' type in the dropdown and it is now working.
I use the following pattern for sending Emails. I’m not sure but maybe you need to use the ActualEmailMsg(MIME.FileName) attribute for message in email.
ActualEmailMsg(MIME.FileName) ="Report_{"+FullFileName+"}.xml";
ActualEmailMsg(SMTP.CC)=ReportNotificationEmailAddress;
ActualEmailMsg(SMTP.Subject)="Report Notification Email";
ActualEmailMsg(SMTP.EmailBodyFile)=#"C:\...\ReportNotificationBody.htm";
ActualEmailMsg(SMTP.Attachments)=#"C:\..\ReportNotificationBody.png”;
ActualEmailMsg (SMTP.EmailBodyTextCharset)="UTF-8";

Deleting mails from IMAP Server

How do i delete mails from IMAP Server. I am using chilkat
Chilkat.EmailBundle bundle = imapClient.FetchHeaders(mset);
There is a method in bundle but it does not delete the mail from Server.
Regards
Sanchaita
There is good documentation (including code examples) on the Chilkat website:
Delete Email Individually (One at a time) from an IMAP Mailbox
Also:
Delete Email from an IMAP Mailbox
Other IMAP examples:
IMAP C# Examples
Hope these help.
Edit:
As per the documentation on the page below:
Chilkat C# EmailBundle Class Reference
Both the RemoveEmail and RemoveEmailByIndex methods only remove the emails from the bundle and not from the server. You will need to use another method as described in the links above to remove the message from the server.
Edit
I am not very familiar with the Chilkat library however from the documentation it seems like the "GetEmail" method in the EmailBundle class will retrieve a mail at a certain index and then you can use the "AppendMail" method in the IMap class to upload the mail to a particular inbox as specified in the following example:
Upload (Append) Email to an IMAP Mailbox
I hope this helps, if it does please mark it as answered.

Categories

Resources