|
I'm writing an IMAP client program to read and display content of e-mails from IMAP servers. I use the command FETCH to read the headers and bodies of these mails and displays them in a text box. But when emails includes
MIME parts, it cannot work correctly. For example when e-mail includes images, the textbox shows only Base64 code. Is there any component other than text box to display MIME parts without writing many codes? Help me, please.
Thanx in advance
|
|
|
|
|
Instead of using a TextBox, why not use the WebBrowser control in cases of HTML mail? If you just want to handle plain-text, you'll have to search for the MIME part using the Content-Type "text/plain", if any. Some readers (mostly based on user preferences) send messages in both plain text and HTML, but other still send only plain text or only HTML. The Content-Type of the message will tell you what it contains. If it is "multipart/alternative" (there's other "multipart" types, see MSDN for details) then search for "text/plain".
If you choose to use MSHTML or the WebBrowser control, it's not a walk in the park. For each image and the like, you have to base64-decode the data and save it as a file. In the HTML, each request to the file has to be mapped correctly so it appears in text. There's other ways to do this, too (IE supports MHTML, which is a manifest format, which is just multipart MIME with the proper MIME type associated with the file).
It just all depends on what you want to do and how much you want to support.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
Thanx but I dont know how to extract body parts of e-mails. In the header the boundary can be xxx but in the body the boundaries can be yyy, zzz ... and xxx. How can I resolve this problem?
|
|
|
|
|
You should first see the RFCs for MIME, first: RFC 2045, RFC 2046, RFC 2048, and RFC 2049. You could also look in the Microsoft Exchange SDK documentation on MSDN.
MIME is delimited with boundaries in a hierarchical fashion based on the MIME multipart header. The hierarchy is the key. Each multipart will have separate boundary delimiters. For example, in a typical HTML mail, you will have something like the following:
Content-Type: multipart/related; boundary="=_A1"; type="multipart/alternative"
| --=_A1
+-Content-Type: multipart/alternativel; boundary="=_B2"
| | --=_B2
| +-Content-Type: text/plain
| | --=_B2
| +-Content-Type: text/html
| | --=_B2--
| --=_A1
+-Content-Type: image/gif
| --=_A1
+-Content-Type: image/jpeg
| --=_A1-- As you can see, each hierarchy has a different boundary delimiters.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
Thanx u very much. You're so kind.
|
|
|
|
|
Hi all,
How can i add images to listview subitems.
Thanks in Advance,
Mahesh
|
|
|
|
|
Man i'm looking for the exact same thing...Thinkin of writing my own listview from scratch...lol
|
|
|
|
|
Hi!
I'm trying out the regular expressions in C# (.NET); but I can't compile my source. The compiler complains about not recognizing "RegularExpressions". Fair enough, I thought. I just need a reference, right?
I have "using System.Text.RegularExpressions;" at the top of my file, of course. Problem is I can't add an assembly reference! When trying to I can't find the System.Text.RegularExpressions dll! I actually tried to seach my whole drive for it, and the only one found was in the compact framework and I can't add that one.
What am I doing wrong here?
PS.: Funny thing is, that the samples folder from the SDK (or maybe the IDE) contains some regular expressions samples with both source and .exe and I can run the .exe without problems (which uses the required dll at runtime)....
|
|
|
|
|
After searching Google groups I found out what to do. I needed to add a reference to System.dll in VS. I was under the impression that the System namespace was referenced by default?
|
|
|
|
|
The name of the DLL (or assembly) is completely unrelated to which namespaces the types it implements are in.
The 'core' namespaces are spread between mscorlib.dll and System.dll. The most critical ones that are required for even the most basic bootstraping are in mscorlib.dll. This isn't just the System namespace, but Collections, IO, Reflection, Remoting, Serialization, Security, etc. The ones that other things don't depend on as much and hence may never need to be loaded are in System.dll. This includes CodeDom, ComponentModel, Net, RegularExpressions, etc.
Don't let the names of the other DLL's fool you either, for example System.Data.dll mostly implements types from the System.Data namespace, but it also implements some types that are in System.Xml and so forth.
-Blake
|
|
|
|
|
Thanks a lot - that was a very helpful answer. It clears all up for me. YAY
|
|
|
|
|
hi all :
I want to make a solution that have 3 projects ,1-web app 2-win app 3-mobile app , iwant to use asp.net web services to link between them all ,the win app is connected to a local DB server(sql server) ,and connect to the internet 1 time per day,and the web app is connected to a remote DB server (sql server) ,and also the mobile app.
the questions are :
1- how can i use Asp.net web services well to make the solution works well?
2-How can i manage the DB ?and how can i make daily transaction to update the remote server with the new data at the local server?? or what??
3-how can i use the same methods for dealing with the DB ,for the win app , the web app and the mobile app?
hadada
MCDBA, MCSD, MSAD
|
|
|
|
|
I have created my own resx file and have embedded it into a dll. I want to create a dll containing all of my app's resources with a class that will retrieve these resources. The problem is, when I do GetObject() it returns a string not an object and I get an invalid cast error. Bellow is my code. The dlls name is Resx.dll and the resource file it contains is Resources.resx. Any ideas???
using System;
using System.Drawing;
using System.Reflection;
...
public class Resx
{
public Resx()
{
}
public static Icon Icon(string resx)
{
Assembly a = Assembly.GetExecutingAssembly();
System.Resources.ResourceManager resources = new
System.Resources.ResourceManager("Resx.Resources", a);
Object o = resources.GetObject(resx);
Console.WriteLine(o.GetType().ToString()); //outputs type String
return (Icon) o;
}
}
|
|
|
|
|
Hi All,
I still having real trouble with this. Any help would be greatly appreciated.
Thanks in advance,
Scott.
|
|
|
|
|
hi all...
i wanna to develop an application to shut down the computer using C#....
i did it and call ExitWondowsEx API......it works fine in windows 98.... but in windows xp
it doesn't work....becauseof the priviliges..... does any one know the code in C# to handle the priviliges??....... or does any one know how to use Sytem.management to shut down the computer???
thx in advance
|
|
|
|
|
I am reading a graphic into an image (Image class) and displaying it on a form. Among other things, I am providing methods for moving the image around on the screen using the mouse. When the user clicks on the image I would like to shade the image (tint?) so that the user knows the image is selected. Similar to (or exactly like) like an icon changes color when the user selects one on the desktop. Any ideas about the best way to do that?
Gary Kirkham
A working Program is one that has only unobserved bugs
I thought I wanted a career, turns out I just wanted paychecks
|
|
|
|
|
graphics.FillRectangle(new SolidBrush(Color.FromArgb(80 ,SystemColors.Highlight)), imageRect);<br />
graphics.DrawRectangle(SystemPens.Highlight, imageRect);
-Blake
|
|
|
|
|
Hey Guys, bit of a C# newby, so if you could point me to a relevant article, or give a few tips would me much appreciated. I've got a file, which I load and decompress to ASCII text in a C++ dll (would have no idea how to do it in C#, unless there's a zip library for C#) and can import that into C# like:
byte * pBuffer=0;
int bytes;
if(DodgyImportFunction(sourceFile,&pBuffer,&bytes))
{
if(bytes>0)
{
//at this point have a pointer to a bytes byte*, but I need it as
//byte[] and C# won't be nice and let me cast it, so I can use it as
//ASCII text.
}
}
Any ideas of a better solution so I can get the decompressed data to be treated as ASCII text in C#?
Thanks, Brian.
|
|
|
|
|
Copy it into a string using Marshal.PtrToStringAnsi().
private static extern bool DodgyImportFunction(
string sourcefile,
ref IntPtr buffer,
ref int bytes
);
IntPtr pBuffer=IntPtr.Zero;
int bytes;
if(DodgyImportFunction(sourceFile,ref pBuffer,ref bytes))
{
if(bytes>0)
{
string str=Marshal.PtrToStringAnsi(pBuffer,bytes);
}
}
"Blessed are the peacemakers, for they shall be called sons of God." - Jesus
"You must be the change you wish to see in the world." - Mahatma Gandhi
|
|
|
|
|
Thanks heaps, that worked a treat!
You ripper, would've taken me ages to work that out.
You beauty!
|
|
|
|
|
Hi!
How does one retrive the IP-address of the remote host? I can only retrive the AddressFamily, and can´t find out how i retrive the address. Can I get the IPEndPoint for the remote host in some way??
søren christensen
|
|
|
|
|
Allow me to answer my own question. To retrive the IP-address og the remote host you can call RemoteEndPoint on the Socket connection, which you the call ToString() on to get IP and port number.
<br />
Socket con = Server.Accept();<br />
<br />
Console.WriteLine( con.RemoteEndPoint.ToString() );<br />
s-christensen
|
|
|
|
|
Hello,
I have been looking at some boooks today to trynd find an example of displaying a bitmap on the screen and I found code hat did not help just give me errors.
How would I draw 'me.gif' on the screen in C# using GDi+?
I would really like your help! ;);P
Cheers,
Rob
|
|
|
|
|
You can draw it on a form using the Graphics.DrawImage() method:
Graphics g = this.CreateGraphics();
g.DrawImage(bmp,new Point(0,0));
HTH
"Blessed are the peacemakers, for they shall be called sons of God." - Jesus
"You must be the change you wish to see in the world." - Mahatma Gandhi
|
|
|
|
|
Hello,
I have a project that uses a MDB file for it’s data. I am trying to make a setup and deployment project to install it the problem I am having is the path in the Crystal Report is seems to be hard coded from the wizard. I want it to use the path the exe is running when I try to set this in the IDE it throws a error. Is there a way to have the setup and deployment project set the path for this or is their a way I can do it?
Thanks for any help.
|
|
|
|