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

Created Unassigned: Downloads 0 kb csv attachment file with error. The input is not a valid Base-64 string as it contains a non-base 64 character [2613]

$
0
0
Hello I have problem with downloading attachment.

I have mail with one attachment in csv(comma delimited) file format.

I need to save to disk F:\Audio\

The library version is: __ImapX 2.0.0.16 Binaries__

The solution is: __CONSOLE APPLICATION__


The Error i'm getting from Visual Studio 2013 Community __.NET 4.5.1__ is:

__An unhandled exception of type 'System.FormatException' occurred in mscorlib.dll__

__Additional information: The input is not a valid Base-64 string as it contains a non-base 64 character, more__ __than two padding characters, or an illegal character among the padding characters.__



the code I'm using so far is:
======================================================================


```

namespace CC_test1
{
class Program
{
static void Main(string[] args)
{
//Setting connecting variables for logging in
string hostname = "this is my host here";
string username = "this is the mail i'm logging in";
string password = "this is the pasword";
string mailBox = "testo";


//Connecting
var client = new ImapClient(hostname, true);
client.IsDebug = true;

if (client.Connect())
{
if (client.Login(username, password))
{
Console.WriteLine("1. IMAP is online");

// Setting behavior of the client
client.Behavior.MessageFetchMode = MessageFetchMode.Full;
client.Behavior.AutoPopulateFolderMessages = true;

//Put all folders in Enumerable
IEnumerable<Folder> folders = client.Folders;

//Access single folder with name "testo"
Folder fld = client.Folders[mailBox];
Console.WriteLine(fld.Name);

//Put all messages from folder "testo" to Enumarable
IEnumerable<Message> msgs = fld.Messages;

//Loop trough all messages in folder "testo"
foreach (var msg in msgs)
{
//Create var to hold message body
MessageBody mbody = msg.Body;

//Print out the body as text
Console.WriteLine(mbody.Text);

//Print out the date
Console.WriteLine(msg.Date);

//Downloading the attachment
string fileDownloadPath = "F:\\Audio";
string fileName = "lw-karaoke-KKKK.csv";
string done = fileDownloadPath;

foreach (var file in msg.Attachments)
{
file.Download();
file.Save(fileDownloadPath);
// I tried with file.Save(fileDownloadPath, fileName); and not working with same error.

}
}
}
Console.ReadLine();
}
}
}
}

```

Viewing all articles
Browse latest Browse all 1952

Trending Articles



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