Reimporting an EML file through IMAP - imap

I have a bunch of .eml files exported/archived using 'archivemail'. Now I need to restore
some the files completely on the IMAP server. Is there some simple tool taking an .eml/mail file with multiple emails and restoring it on an IMAP server

You can use Mail.dll .NET IMAP library for that:
using (Imap imap = new Imap())
{
imap.Connect("server"); // or ConnectSSL
imap.Login("user", "password");
string eml = File.ReadAllText("email.eml");
imap.UploadMessage("INBOX", eml);
imap.Close();
}
Mail.dll can also parse the .eml files if you need to implement some custom logic before uploading:
IMail email = new MailBuilder().CreateFromEml(eml);
Please note however that this is a commercial product I helped to develop.

Related

creating CSV file in local drive with asp.net in azure

I have a webapp in which i can create csv file and locate it in my c drive,
It works fine when running locally, but once i deploy the application to Azure
I'm getting :
UnauthorizedAccessException: Access to the path 'C:\Tuesday_HH19_MI6.csv' is denied.
How can i allow the website to access and create a file in the user's local drive?
I attached the entire log exception from azure if this helps,
Thank you
A Web App running in Azure can't directly save it to your user's local drive, but it can generate the CSV and then prompt them to download it via the browser. You can use a few options depending on if you are trying to send that already exists on the filesystem or if you have generated it dynamically and have it as a byte array or stream.
Here are some sample controller methods to give you and idea. Your controller could be doing a bunch of stuff before the return statement, these examples are simplified.
Existing file on filesystem, use a FileResult:
public FileResult DownloadFile()
{
// create the file etc and save to FS
return File("/Files/File Result.pdf", "text/csv", "MyFileName.csv");
}
If the file is generated in memory and you have it as a byte array:
public FileContentResult DownloadContent()
{
// Create CSV as byte array
var myfile = MyMethodtoCreateCSV();
return new FileContentResult(myfile, "text/csv") {
FileDownloadName = "MyFileName.csv"
};
}

How to extract attachment from application/pkcs7-mime received from Microsoft Graph API in .NET Core

I am downloading attachments with Microsoft Graph API in .NET Core 3.1.
await client.Users[mail.OwnerEmail].Messages[mail.Id].Attachments.Request().GetAsync()
Recently one email had strange attachment with content type application/pkcs7-mime (extension .p7m). I need to extract attachments inside this signed attachment. Outlook shows 2 attachments for this mail: pdf and xml. I need these 2 files.
I found this thread, but I don't understand the answer.
I tried:
var signed = new SignedCms();
signed.Decode(signedAttachment.Content); //Exception: ASN1 corrupted data.
and
new SignedCms(new ContentInfo(signedAttachment.Content))
and receive some friendly name and version:
but I don't know how to extract attachments.
Edited:
Also tried:
var envelopedCms = new EnvelopedCms();
envelopedCms.Decode(signedAttachment.Content);
and Decrypt ... Nothing.

Reading File on Google Drive using Dart

I created a configuration file (Simple Text File) on my Google Drive and now I would like to read it from my Chrome Packaged Dart Application. But I'm not able to get more information of the file than it's name, size etc.
For accessing Google Drive I use the google_drive_v2_api.
Any suggestion on how to get the contents of my configuration file would be great! Thanks!
I just did some test in my own chrome app, uploading and downloading a simple file:
chrome.identity.getAuthToken(new chrome.TokenDetails(interactive: true ))
.then((token){
OAuth2 auth = new SimpleOAuth2(token);
var drive = new gdrive.Drive(auth)..makeAuthRequests=true;
drive.files.insert({},content:window.btoa('hello drive!')).then((sentMeta){
print("File sent! Now retrieving...");
drive.files.get(sentMeta.id).then((repliedMeta){
HttpRequest request = new HttpRequest()..open('GET', repliedMeta.downloadUrl)
..onLoad.listen((r)=>print('here is the result:'+r.target.responseText));
auth.authenticate(request).then((oAuthReq)=>oAuthReq.send());
});
});
});
It works, but the HttpRequest to get content back seems heavy...
But i really recommend you to a take look to chrome.storage.sync if your config file size is < to 4ko... If not, you could also use the chrome SyncFileSystem API... They are both easier to use, and SyncFileSystem use Drive as backend.
This page on downloading files talks through the process for getting the contents of a file.

uploading a file from iOS mobile application to SharePoint

I'm working on a SharePoint mobile solution where I'm using the web services exposed in server/_vti_bin/sitedata.asmx, server/_vti_bin/Lists.asmx and server/_vti_bin/copy.asmx.
I'm able to successfully fetch the list of sites, document libraries and files using the services defined in server/_vti_bin/sitedata.asmx.
Now I'm actually trying to upload an image file from Photo Albums available in iOS to SharePoint. For this, I tried using CopyIntoItems web service, where in I'm getting the following error response.
<CopyResult ErrorCode="DestinationInvalid" ErrorMessage="The Copy web service method must be called on the same domain that contains the destination url." DestinationUrl="http://xxxxserveripxxxxxx/Shared Documents/image1.png"/>
But came to know that this service is used only if the file to be uploaded is also from the same source(i.e., from sharepoint).
Is there any other way to upload a file available in iPhone to SharePoint.
Also tired addAttachment service defiend in server/_vti_bin/Lists.asmx but I'm unable to identify the input parameters which requires list name and list Item ID.
I'm trying to upload a file to Shared Documents, so I've List Name value which is the one in curly braces of Shared Documents but now what should be the List Item Id value?
These are the details I've with regard to "Shared Documents" document library.
{
AllowAnonymousAccess = false;
AnonymousViewListItems = false;
BaseTemplate = DocumentLibrary;
BaseType = DocumentLibrary;
DefaultViewUrl = "/Shared Documents/Forms/AllItems.aspx";
Description = "Share a document with the team by adding it to this document library.";
InheritedSecurity = true;
InternalName = "{425F837A-F110-4876-98DE-C92902446935}";
LastModified = "2013-07-26 20:09:58Z";
ReadSecurity = 1;
Title = "Shared Documents";
},
So, I'm using the using InternalName value for listName tag.
What should be the value of listItemID?
Am I going in the right way or is there any other approach to upload a local file from mobile to SharePoint?
Thanks
Sudheer
Are you actually calling a URL or are you using the IP (you x'ed it out and said server IP)? If you don't have Alternate Access Mappings defined for the IP, uploads will fail but the GET requests will generally work ok.

Using MVC to talk directly to Amazon S3

I am writing an MVC 3 application that needs to allow the user to directly upload a file to S3. I also need to show a progress bar. All of the examples I have seen are PHP or Ruby-on-Rails related. Has anyone managed to upload a file to S3 directly (from client browser) using MVC?
So, after a morning of smashing my head into my keyboard, the following snippet of code works (with the obvious credentials removed):
using (AmazonS3 client = Amazon.AWSClientFactory.CreateAmazonS3Client("Access_Key",
"Secret_Key"))
{
PutObjectRequest request = new PutObjectRequest();
request.WithBucketName("BUCKET-NAME")
.WithCannedACL(S3CannedACL.PublicRead)
.WithKey("myDirectory/" +
HttpContext.Current.Server.UrlEncode(fileBase.FileName))
.InputStream = fileBase.InputStream;
S3Response response = client.PutObject(request);
}

Resources