D
David
I have a C# application that functions as follows:
1. Log onto a pop3 mail account
2. search for any messages from a given source.
3. Get the attachment from the message. (This attachment will ALWAYS
be a TIFF file).
4. store new tiff file on local server.
I have everything working except the file I save cannot be viewed.
I'm sure its because of the formating of the string I store in the
file.
I need help converting the string to the correct format before storing
into a TIF file.
Following is the current code snippet.
startPos = msgStr.IndexOf("attachment;",0);
if( startPos != -1 )
{
startPos = msgStr.IndexOf("filename=",startPos);
startPos = startPos + 10;
endPos = msgStr.IndexOf("\r\n",startPos);
Console.WriteLine ("You have an attachment: " +
msgStr.Substring(startPos, endPos - startPos - 1));
//this will create the new file
strFileName = @"c:\temp\" + msgStr.Substring(startPos, endPos -
startPos - 1);
FileStream fs = File.OpenWrite(strFileName);
byte[] by = System.Text.Encoding.ASCII.GetBytes(msgStr.Substring(endPos
+ 1).ToString());
fs.Write(by,0,by.Length);
fs.Close();
}
else
{
Console.WriteLine ("No attachement.");
}
1. Log onto a pop3 mail account
2. search for any messages from a given source.
3. Get the attachment from the message. (This attachment will ALWAYS
be a TIFF file).
4. store new tiff file on local server.
I have everything working except the file I save cannot be viewed.
I'm sure its because of the formating of the string I store in the
file.
I need help converting the string to the correct format before storing
into a TIF file.
Following is the current code snippet.
startPos = msgStr.IndexOf("attachment;",0);
if( startPos != -1 )
{
startPos = msgStr.IndexOf("filename=",startPos);
startPos = startPos + 10;
endPos = msgStr.IndexOf("\r\n",startPos);
Console.WriteLine ("You have an attachment: " +
msgStr.Substring(startPos, endPos - startPos - 1));
//this will create the new file
strFileName = @"c:\temp\" + msgStr.Substring(startPos, endPos -
startPos - 1);
FileStream fs = File.OpenWrite(strFileName);
byte[] by = System.Text.Encoding.ASCII.GetBytes(msgStr.Substring(endPos
+ 1).ToString());
fs.Write(by,0,by.Length);
fs.Close();
}
else
{
Console.WriteLine ("No attachement.");
}