Quantcast
Channel: ImapX 2
Viewing all articles
Browse latest Browse all 1952

Created Unassigned: Problem to save xls file [2825]

$
0
0
Hi,

Im trying to save a xls attachment but im having this error:,

An unhandled exception of type 'System.FormatException' occurred in mscorlib.dll

Additional information: The entry is not a valid Base 64 string because it contains a non-base 64 character, more than two fill-in characters, or an illegal character between the fill characters.

The name of the downloaded file is "OrdemServicoRecebida_FOTOTICA_2017-02-07.xls"

Im using this code to save the file:

the error is on the "atts[j].Save(SAVE_LOCATION, atts[j].FileName);" line

```
FolderCollection folders = client.Folders;
Message[] messages = client.Folders["INBOX"].Search("ALL", MessageFetchMode.Attachments, 100);

var SAVE_LOCATION = @"c:\files\";

for (int i = 0; i < messages.Length; i++)
{
if (messages[i].Attachments.Length > 0)
{
Attachment[] atts = messages[i].Attachments;
for (int j = 0; j < atts.Length; j++)
{
if (atts[j].FileName.Contains("xls") || atts[j].FileName.Contains("xlsx"))
{
atts[j].Download();
atts[j].Save(SAVE_LOCATION, atts[j].FileName);
}
}
}
}
```

How can i fix it?

Viewing all articles
Browse latest Browse all 1952

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>