PC Review


Reply
Thread Tools Rate Thread

How to convert a String to Tiff from a POP3 message

 
 
David
Guest
Posts: n/a
 
      22nd Aug 2003
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.");
}
 
Reply With Quote
 
 
 
 
Paul Coulson
Guest
Posts: n/a
 
      22nd Aug 2003
Hi David,

I believe attachments are Base64 encoded, you can use the
Convert.FromBase64() method prior to saving the file.


Paul

"David" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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.");
> }



 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
convert tiff to pdf MikeIMSCorp Microsoft Outlook Installation 2 30th Mar 2010 09:23 PM
convert to tiff or jpg ryker Microsoft Excel Discussion 1 7th Mar 2007 01:35 PM
Convert from DOC -> TIFF =?Utf-8?B?QWxhbiBUYW5n?= Microsoft Windows 2000 CMD Promt 0 22nd Aug 2005 07:44 AM
Convert PPT to EPS or TIFF? Peter Frank Microsoft Powerpoint 11 27th May 2005 01:46 PM
How to convert a String to Tiff from a POP3 message David Microsoft C# .NET 0 22nd Aug 2003 02:04 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 11:17 AM.