I'm trying to Zip and send .csv files using C#. I create the files, zip them and send them using an SMTP Gmail host.
It can sometimes take this email several hours to reach it's destination. For testing I am using very small files so size isn't an issue.
If I try to "manually" send these zips using gmail I get the following error: "myFile.csv.zip contains an executable file. For security reasons, Gmail does not allow you to send this type of file."
I think there might be a problem with my compression method but it's very straight forward:
string compressedFile = fileName + ".zip";
FileInfo fi = new FileInfo(fileName);
using (FileStream inFile = fi.OpenRead())
{
using (FileStream outFile = File.Create(compressedFile))
{
using (GZipStream Compress = new GZipStream(outFile, CompressionMode.Compress))
{
inFile.CopyTo(Compress);
Compress.Close();
}
outFile.Dispose();
}
}
return compressedFile;
Just a note: If I take the same file and manually Zip or rar it I have no problem. This happens with text files too.