|
|
 Prize winner in Competition
"MFC/C++ Nov 2004"
Comments and Discussions
|
|
 |

|
I want to save mail attachments, with the help of code. Plz help me...
VIPLAV AGARWAL
|
|
|
|

|
if u have some idea then give me , how we can read .dbx file and deleted mail from outlook express.
naveen padiyar
|
|
|
|

|
Hi,
The article was very nice but it is in C++. Can i have sample code for Outlook bounced emails.
Here I'm posting sample code:
ApplicationClass myOutlookApplication = new ApplicationClass ();
NameSpace myNameSpace = myOutlookApplication.GetNamespace("MAPI");
object myMissing = System.Reflection.Missing.Value;
myNameSpace.Logon(ConfigData.MailServer as object, myMissing, false, true);
MAPIFolder theInbox = myNameSpace.GetDefaultFolder(OlDefaultFolders.olFolderInbox);
for (int i=theInbox.Items.Count-1; i -1) ||
(senderEmail.IndexOf("mail delivery subsystem") > -1) ||
(subject.IndexOf("returned") > -1) )
{
Read attachments and look for specific string here..
}
..
thank you,
Regards
ParsiB
|
|
|
|

|
Also I need the code in C#.
Thank you.
|
|
|
|

|
Hi Pablo,
I am able to create an instance of IMimeMessage using CoCreateInstance(). How to use this IMimeMessage interface pointer to read an EML file?
Any help in this direction would be great.
Thanks,
Prasad
|
|
|
|

|
Hi,
Where can i get the iid, clsid, and interface of the IMimeMessageW?
Thanx
|
|
|
|

|
You need mimeole.h (compile mimeole.idl from SDK - see below - also check MSDN for extra info)
Tip:
If you have SDK on your machine you might find all the .idl but no .h file (a great example is msoeapi.h) so what to do?.
Add .idl file in your project (any project) and compile either the project or the .idl file.
If you use the default VS2005 settings (should be similar to other versions) a .h file (and also two .c files - not needed for our purpose) with the project name should be created after you compile/build. If you open it it's the .h that has all the interface referece. You just need to rename that file with a proper and you are ready to code.
Now I did this with msoeapi.idl but somehow the output .h file was missing a reference and a bunch of declaration were different (difference in the .idl probably). I had to cross reference with this project's file with mine and then added the following
typedef enum tagIMSGPRIORITY {
IMSG_PRI_LOW = 5,
IMSG_PRI_NORMAL = 3,
IMSG_PRI_HIGH = 1
} IMSGPRIORITY;
I am not sure why this is missing. I substituted my new msoeapi.h into this project and everything seems to work.
Cheers
|
|
|
|

|
A little correct or two for the above tip.
The reason I didn't have IMSGPRIORITY defined is because I didn't compile mimeole.idl which is included in msoeapi.h in 2003 SDK. This project probably used a older version of the SDK which didn't require mimeole.h.
Also the output .h file might not necessarily be the project name since after compiling mimeole.ild I got mimeole_h.h but a .h file should be created for sure.
|
|
|
|

|
Don't forget to include #include as well or you will get link errors.
|
|
|
|

|
Hi Pablo,
This is a very great article, probably the only one that shows how to use OE interfaces provided by MS.
But, I want to write message event handlers for OE. The requirement is:
1.) When I compose a new mail in OE and press 'Send' button then before the compose window is closed I want to take control of message by obtaining the messageID. I want to scan for any attachments, zip the attachments then remove original attachments from mail and put back the zipped one.
2.) When user tries to read a new mail then I would like to take control over the message, get the messageID, scan for any .zip attachment, unzip the file then remove the .zip file from mail, put back the extracted files to mail and let OE render the mail.
In short, I want to manipulate the composed message before it is sent and also manipulate the message in Inbox before it is displayed.
I don't want to do any UI hooking/hacking here. I want to do it cleanly by using the interfaces you mentioned here.
|
|
|
|

|
i read your article, i learn much thing from the article.Thank you!
i find the project don't wirte a HTML email into express,but i want do it.
can you tell me how to write a HTML email into express? Thank you.
|
|
|
|

|
Hi,
Great article. I prefer OE for email but it's spam filtering is worthless. I'm looking for articles like this to get me started on writing OE plugins so that I can make my own. Thanks.
But, how do you implement drag/drop of messages? I've previously written an OE app which processed messages but the user has to drag-n-drop the messages to a folder and then the files to the app. I would like to allow them to drag-n-drop the messages staright from OE to the app.
Thanks a lot.
--
Synetech
|
|
|
|

|
thanks for your a very use full app
i would like to load all messages programmatically from my mailbox yahoo;
as I do with menu item "receive&send" email in outlook,
is-it possible ? Witch interface to invoke ?
sorry for my bad english,
tanks so much.
-- modified at 1:04 Wednesday 19th July, 2006
|
|
|
|

|
This is a great artical, probably the best artical I found so far related to outlook express.
I'd like to add a menu to outlook express. Any suggestions?
Thanks.
--Yajun
|
|
|
|

|
Hi,
You have to run your code inside OE process. See PGP example to know how it can be achieved.
I have never added an additional menu in OE 6, I know that it can be done in OE 5 because PGP did it.
Regards,
Pablo Yabo.
|
|
|
|

|
Hi Yajun,
You can reference here if you haven't done yet.
Best regards,
soricere_vn
|
|
|
|

|
Is there an efficient method of determining if a email message contains any attachments?
According to the documentation dwFlags in the MESSAGEPROPS specifies the state of the message. One of the states is IMF_ATTACHMENTS - Indicates that the message has attachments. Unfortunately every message dwFlags is zero?
Thanks in advance.
Danny
|
|
|
|

|
Hi,
You can use IMimeMessage::GetAttachments to list all body handles that are attachments.
Regards,
Pablo Yabo.
|
|
|
|

|
Hi Pablo,
Yes but I am trying to obtain this information efficiently.
Basically I would like to list all the messages in a folder. Similar to Outlook Express it would be nice to indicate in the email has any attachments. I don't need any details of the attachments, only if some exists.
Thanks,
Danny
|
|
|
|

|
We need to automate the outlook express 6 for reading folders etc. We could not get any good article than yours. The article is very good.
how can this be carried out using Visual Basic 6.0? Can we reference your code from VB?
any help on this is appreciated.
kram
|
|
|
|

|
I'm not and expert of VB. I think that you can use it only if you know internals. I know someone that made it work with VB but I didn't see that code.
The problem is that you have to force VB to use the VTable that is in the header file because the typelibrary is not registered.
Pablo
|
|
|
|

|
Hi,
I'm currently programming a win32 service and need to retrieve local user(s) OE folders and message.
But when I execute your code from within my service it only retrieve System's user folders (default OE folders). Is there a way to specify that we want to access another user's folders. Please give me hints or tell me I can't do it !
Thanks a lot.
|
|
|
|

|
Hi,
The problem using this code from a service is that OE data is owned by each user and your service should be running as SYSTEM user and it's not related to any user and you cannot choose the user using OE API.
Regards,
Pablo Yabo.
|
|
|
|

|
Ok, that was what i thought.
So, there isn't any way to choose the user with this API.
Thank for your reply !
|
|
|
|

|
I think you can try to use another interface - IMessageStore. You can initialize it using the absolute path (in terms of file system) to the folder which contains the .dbx files. For example (on my machine) it is "C:\Documents and Settings\Alexey\Local Settings\Application Data\Identities\{}\Microsoft\Outlook Express". After proper initialization you will have access to whole tree of OE's folders located in this file folder.
You can get the instance using simple call of CoCreateInstance:
IMessageStore* p_store = NULL;
...
HRESULT hr = ::CoCreateInstance(CLSID_MessageStore,NULL,CLSCTX_INPROC_SERVER,IID_IMessageStore,(void**)&store );
if (FAILED(hr) || (p_store == NULL)) return E_FAIL;
hr = p_store->Initialize(sz_path_to_dbx_folder);
...
Then you can use member functions:
EnumChildren - to enumerate folders,
OpenFolder - to open folder,
OpenSpecialFolder... and so on.
They works very like the ones from IStoreNamespace (actually these members of IStoreNamespace delegate their calls to IMessageStore). If you see, for example, OpenFolder (in difference with such member from IStoreNamespace) returns the pointer to IMessageFolder, instead of IStoreFolder - and also wait for parameter IMessageServer.
Actually you can use IMessageFolder as more general version of IStoreFolder.
hm... I think I can summ the knowledge of internal OE structures into standalone article here on CodeProject, how you think? :->
Below is the necessary declarations (they are non-official - so, it may contain misstypes; be careful!)
// {101A8FB9-F1B9-11d1-9A56-00C04FA309D4}
DEFINE_GUID(CLSID_MessageStore, 0x101A8FB9, 0xF1B9, 0x11d1, 0x9A, 0x56, 0x0, 0xC0, 0x4F, 0xA3, 0x09, 0xD4);
// {E883FC75-EC08-11D1-9A53-00C04FA309D4}
DEFINE_GUID(IID_IMessageStore, 0xE883FC75, 0xEC08, 0x11D1, 0x9A, 0x53, 0x0, 0xC0, 0x4F, 0xA3, 0x09, 0xD4);
struct tagMESSAGEINFO;
typedef tagMESSAGEINFO MESSAGEINFO, __RPC_FAR *LPMESSAGEINFO;
struct tagFINDINFO;
struct tagGETCOUNTTYPE;
struct tagAPPLYCHILDRENTYPE;
struct tagMARK_TYPE;
struct tagFOLDERSORTINFO;
struct tagGETNEXTTYPE;
struct tagROWMESSAGETYPE;
struct tagRELATIVEROWTYPE;
//struct tagADJUSTFLAGS;
struct tagFINDNEXTFLAGS;
struct tagFOLDER_OPTIONS;
interface IListSelector;
interface IMessageServer;
interface IMessageTableNotify;
typedef DWORD MESSAGEID__;
typedef unsigned long FOLDERID__;
typedef DWORD tagADJUSTFLAGS;
interface IStoreCallback : public IUnknown
{
};
struct HLOCK__;
struct tagTABLEINDEX;
//struct tagTRANSACTIONTYPE;
struct tagRESULTLIST;
struct tagFOLDERINFO;
struct HROWSET__;
struct HTRANSACTION__;
typedef unsigned short ushort;
typedef unsigned char uchar;
interface IDatabaseNotify;
interface IDatabaseProgress;
interface IDatabase;
interface IEnumerateFolders;
interface IImnAccount;
interface IMessageFolder;
interface IMessageStore : public IUnknown
// CLSID_MessageStore = {101A8FB9-F1B9-11d1-9A56-00C04FA309D4}
// IID_IMessageStore = {E883FC75-EC08-11D1-9A53-00C04FA309D4}
{
virtual HRESULT STDMETHODCALLTYPE Lock(HLOCK__ * *);
virtual HRESULT STDMETHODCALLTYPE Unlock(HLOCK__ * *);
virtual HRESULT STDMETHODCALLTYPE InsertRecord(void *);
virtual HRESULT STDMETHODCALLTYPE UpdateRecord(void *);
virtual HRESULT STDMETHODCALLTYPE DeleteRecord(void *);
virtual HRESULT STDMETHODCALLTYPE FindRecord(unsigned long,unsigned long,void *,unsigned long *);
virtual HRESULT STDMETHODCALLTYPE GetRowOrdinal(unsigned long,void *,unsigned long *);
virtual HRESULT STDMETHODCALLTYPE FreeRecord(void *);
virtual HRESULT STDMETHODCALLTYPE GetUserData(void *,unsigned long);
virtual HRESULT STDMETHODCALLTYPE SetUserData(void *,unsigned long);
virtual HRESULT STDMETHODCALLTYPE GetRecordCount(unsigned long,unsigned long *);
virtual HRESULT STDMETHODCALLTYPE GetIndexInfo(unsigned long,char * *,struct tagTABLEINDEX *);
virtual HRESULT STDMETHODCALLTYPE ModifyIndex(unsigned long,char const *,struct tagTABLEINDEX const *);
virtual HRESULT STDMETHODCALLTYPE DeleteIndex(unsigned long);
virtual HRESULT STDMETHODCALLTYPE CreateRowset(unsigned long,unsigned long,struct HROWSET__ * *);
virtual HRESULT STDMETHODCALLTYPE SeekRowset(struct HROWSET__ *,enum tagSEEKROWSETTYPE,long,unsigned long *);
virtual HRESULT STDMETHODCALLTYPE QueryRowset(struct HROWSET__ *,long,void * *,unsigned long *);
virtual HRESULT STDMETHODCALLTYPE CloseRowset(struct HROWSET__ * *);
virtual HRESULT STDMETHODCALLTYPE CreateStream(unsigned long *);
virtual HRESULT STDMETHODCALLTYPE DeleteStream(unsigned long);
virtual HRESULT STDMETHODCALLTYPE CopyStream(struct IDatabase *,unsigned long,unsigned long *);
virtual HRESULT STDMETHODCALLTYPE OpenStream(enum tagACCESSTYPE,unsigned long,struct IStream * *);
virtual HRESULT STDMETHODCALLTYPE ChangeStreamLock(struct IStream *,enum tagACCESSTYPE);
virtual HRESULT STDMETHODCALLTYPE RegisterNotify(unsigned long,unsigned long,unsigned long,IDatabaseNotify *);
virtual HRESULT STDMETHODCALLTYPE DispatchNotify(struct IDatabaseNotify *);
virtual HRESULT STDMETHODCALLTYPE SuspendNotify(struct IDatabaseNotify *);
virtual HRESULT STDMETHODCALLTYPE ResumeNotify(struct IDatabaseNotify *);
virtual HRESULT STDMETHODCALLTYPE UnregisterNotify(struct IDatabaseNotify *);
virtual HRESULT STDMETHODCALLTYPE LockNotify(unsigned long,struct HLOCK__ * *);
virtual HRESULT STDMETHODCALLTYPE UnlockNotify(struct HLOCK__ * *);
virtual HRESULT STDMETHODCALLTYPE GetTransaction(struct HTRANSACTION__ * *,enum tagTRANSACTIONTYPE *,void *,void *,unsigned long *,struct tagORDINALLIST *);
virtual HRESULT STDMETHODCALLTYPE MoveFileA(unsigned short const *);
virtual HRESULT STDMETHODCALLTYPE SetSize(unsigned long);
virtual HRESULT STDMETHODCALLTYPE Repair(void);
virtual HRESULT STDMETHODCALLTYPE Compact(struct IDatabaseProgress *,unsigned long);
virtual HRESULT STDMETHODCALLTYPE HeapAllocate(unsigned long,unsigned long,void * *);
virtual HRESULT STDMETHODCALLTYPE HeapFree(void *);
virtual HRESULT STDMETHODCALLTYPE GenerateId(unsigned long *);
virtual HRESULT STDMETHODCALLTYPE GetClientCount(unsigned long *);
virtual HRESULT STDMETHODCALLTYPE GetFile(unsigned short * *);
virtual HRESULT STDMETHODCALLTYPE GetSize(unsigned long *,unsigned long *,unsigned long *,unsigned long *);
virtual HRESULT STDMETHODCALLTYPE Initialize(LPCSTR pszPath);
virtual HRESULT STDMETHODCALLTYPE Validate(unsigned long);
virtual HRESULT STDMETHODCALLTYPE GetDirectory(int,LPSTR lpString1,int iMaxLength);
virtual HRESULT STDMETHODCALLTYPE Synchronize(FOLDERID__ *,unsigned long,struct IStoreCallback *);
virtual HRESULT STDMETHODCALLTYPE FindServerId(char const *,FOLDERID__ * *);
virtual HRESULT STDMETHODCALLTYPE CreateServer(IImnAccount *,ULONG,FOLDERID__ * *);
virtual HRESULT STDMETHODCALLTYPE CreateFolder(ULONG,tagFOLDERINFO *,IStoreCallback *);
virtual HRESULT STDMETHODCALLTYPE OpenSpecialFolder(FOLDERID__ *,IMessageServer *,uchar,IMessageFolder**);
virtual HRESULT STDMETHODCALLTYPE OpenFolder(FOLDERID__ *,IMessageServer *,ULONG,IMessageFolder**);
virtual HRESULT STDMETHODCALLTYPE MoveFolder(FOLDERID__ *,FOLDERID__ *,ULONG,IStoreCallback *);
virtual HRESULT STDMETHODCALLTYPE RenameFolder(FOLDERID__ *,char const *,ULONG,IStoreCallback *);
virtual HRESULT STDMETHODCALLTYPE DeleteFolder(FOLDERID__ *,ULONG,IStoreCallback *);
virtual HRESULT STDMETHODCALLTYPE GetFolderInfo(FOLDERID__ *,tagFOLDERINFO *);
virtual HRESULT STDMETHODCALLTYPE GetSpecialFolderInfo(FOLDERID__ *,uchar,tagFOLDERINFO *);
virtual HRESULT STDMETHODCALLTYPE SubscribeToFolder(FOLDERID__ *,int,IStoreCallback *);
virtual HRESULT STDMETHODCALLTYPE HrSetNoSecUICallback(ULONG,long (*)(ULONG));
virtual HRESULT STDMETHODCALLTYPE UpdateFolderCounts(FOLDERID__ *,long,long,long,long);
virtual HRESULT STDMETHODCALLTYPE EnumChildren(FOLDERID__ *,int,IEnumerateFolders **);
virtual HRESULT STDMETHODCALLTYPE GetAdvise(ULONG *,ULONG *,IAdviseSink * *);
};
interface IMessageFolder : public IUnknown
{
virtual HRESULT STDMETHODCALLTYPE Lock(HLOCK__ * *);
virtual HRESULT STDMETHODCALLTYPE Unlock(HLOCK__ * *);
virtual HRESULT STDMETHODCALLTYPE InsertRecord(void *);
virtual HRESULT STDMETHODCALLTYPE UpdateRecord(void *);
virtual HRESULT STDMETHODCALLTYPE DeleteRecord(void *);
virtual HRESULT STDMETHODCALLTYPE FindRecord(ULONG,ULONG,void *,ULONG *);
virtual HRESULT STDMETHODCALLTYPE GetRowOrdinal(ULONG,void *,ULONG *);
virtual HRESULT STDMETHODCALLTYPE FreeRecord(void *);
virtual HRESULT STDMETHODCALLTYPE GetUserData(void *,ULONG);
virtual HRESULT STDMETHODCALLTYPE SetUserData(void *,ULONG);
virtual HRESULT STDMETHODCALLTYPE GetRecordCount(ULONG,ULONG *);
virtual HRESULT STDMETHODCALLTYPE GetIndexInfo(ULONG,char * *,tagTABLEINDEX *);
virtual HRESULT STDMETHODCALLTYPE ModifyIndex(ULONG,char const *,tagTABLEINDEX const *);
virtual HRESULT STDMETHODCALLTYPE DeleteIndex(ULONG);
virtual HRESULT STDMETHODCALLTYPE CreateRowset(ULONG,ULONG,HROWSET__ * *);
virtual HRESULT STDMETHODCALLTYPE SeekRowset(HROWSET__ *,tagSEEKROWSETTYPE,long,ULONG *);
virtual HRESULT STDMETHODCALLTYPE QueryRowset(HROWSET__ *,long,void * *,ULONG *);
virtual HRESULT STDMETHODCALLTYPE CloseRowset(HROWSET__ * *);
virtual HRESULT STDMETHODCALLTYPE CreateStream(ULONG *);
virtual HRESULT STDMETHODCALLTYPE DeleteStream(ULONG);
virtual HRESULT STDMETHODCALLTYPE CopyStream(IDatabase *,ULONG,ULONG *);
virtual HRESULT STDMETHODCALLTYPE OpenStream(tagACCESSTYPE,ULONG,IStream * *);
virtual HRESULT STDMETHODCALLTYPE ChangeStreamLock(IStream *,tagACCESSTYPE);
virtual HRESULT STDMETHODCALLTYPE RegisterNotify(ULONG,ULONG,ULONG,IDatabaseNotify *);
virtual HRESULT STDMETHODCALLTYPE DispatchNotify(IDatabaseNotify *);
virtual HRESULT STDMETHODCALLTYPE SuspendNotify(IDatabaseNotify *);
virtual HRESULT STDMETHODCALLTYPE ResumeNotify(IDatabaseNotify *);
virtual HRESULT STDMETHODCALLTYPE UnregisterNotify(IDatabaseNotify *);
virtual HRESULT STDMETHODCALLTYPE LockNotify(ULONG,HLOCK__ * *);
virtual HRESULT STDMETHODCALLTYPE UnlockNotify(HLOCK__ * *);
virtual HRESULT STDMETHODCALLTYPE GetTransaction(HTRANSACTION__ * *,tagTRANSACTIONTYPE *,void *,void *,ULONG *,tagORDINALLIST *);
virtual HRESULT STDMETHODCALLTYPE MoveFileA(ushort const *);
virtual HRESULT STDMETHODCALLTYPE SetSize(ULONG);
virtual HRESULT STDMETHODCALLTYPE Repair(void);
virtual HRESULT STDMETHODCALLTYPE Compact(IDatabaseProgress *,ULONG);
virtual HRESULT STDMETHODCALLTYPE HeapAllocate(ULONG,ULONG,void * *);
virtual HRESULT STDMETHODCALLTYPE HeapFree(void *);
virtual HRESULT STDMETHODCALLTYPE GenerateId(ULONG *);
virtual HRESULT STDMETHODCALLTYPE GetClientCount(ULONG *);
virtual HRESULT STDMETHODCALLTYPE GetFile(ushort * *);
virtual HRESULT STDMETHODCALLTYPE GetSize(ULONG *,ULONG *,ULONG *,ULONG *);
virtual HRESULT STDMETHODCALLTYPE Initialize(IMessageStore *,IMessageServer *,ULONG,FOLDERID__ *);
virtual HRESULT STDMETHODCALLTYPE ContextSensitiveHelp(int);
virtual HRESULT STDMETHODCALLTYPE UpdateRegistry(int);
virtual HRESULT STDMETHODCALLTYPE GetFolderId(FOLDERID__ * *);
virtual HRESULT STDMETHODCALLTYPE GetMessageFolderId(MESSAGEID__ *,FOLDERID__ * *);
virtual HRESULT STDMETHODCALLTYPE GetAdvise(ULONG *,ULONG *,IAdviseSink * *);
virtual HRESULT STDMETHODCALLTYPE OpenMessage(MESSAGEID__ *,ULONG,IMimeMessage * *,IStoreCallback *);
virtual HRESULT STDMETHODCALLTYPE SaveMessage(MESSAGEID__ * *,ULONG,ULONG,IStream *,IMimeMessage *,IStoreCallback *);
virtual HRESULT STDMETHODCALLTYPE HrSetNoSecUICallback(ULONG,long (*)(ULONG));
virtual HRESULT STDMETHODCALLTYPE SetMessageFlags(tagMESSAGEIDLIST *,tagADJUSTFLAGS *,tagRESULTLIST *,IStoreCallback *);
virtual HRESULT STDMETHODCALLTYPE CopyMessages(IMessageFolder *,ULONG,tagMESSAGEIDLIST *,tagADJUSTFLAGS *,tagRESULTLIST *,IStoreCallback *);
virtual HRESULT STDMETHODCALLTYPE DeleteMessages(ULONG,tagMESSAGEIDLIST *,tagRESULTLIST *,IStoreCallback *);
virtual HRESULT STDMETHODCALLTYPE ResetFolderCounts(ULONG,ULONG,ULONG,ULONG);
virtual HRESULT STDMETHODCALLTYPE IsWatched(char const *,char const *);
virtual HRESULT STDMETHODCALLTYPE GetDatabase(IDatabase * *);
virtual HRESULT STDMETHODCALLTYPE ConnectionRelease(void);
virtual HRESULT STDMETHODCALLTYPE ConnectionRelease1(void);
virtual HRESULT STDMETHODCALLTYPE ContextSensitiveHelp1(int);
};
|
|
|
|
 |
|
|
General News Suggestion Question Bug Answer Joke Rant Admin
Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.
|
This article was done to provide an example of IStoreNamespace / IStoreFolder.
| Type | Article |
| Licence | |
| First Posted | 28 Dec 2004 |
| Views | 334,786 |
| Bookmarked | 104 times |
|
|