How to get outlook attachment event?
-
Hi, I have an application which uses ShellExecuteEx function to launch Outlook and attaching file. ************************************************************ shExecInfo.fMask = SEE_MASK_NOCLOSEPROCESS ; shExecInfo.hwnd = NULL; shExecInfo.lpVerb = "open"; shExecInfo.lpFile = "outlook"; shExecInfo.lpParameters = "C:\Test.doc"; shExecInfo.lpDirectory = NULL; shExecInfo.nShow = SW_MAXIMIZE; shExecInfo.hInstApp = NULL; ShellExecuteEx(&shExecInfo); ************************************************************ I am using this functionality in my app ins such a way that once file attached i am proceeding with other functionality. But my problem is before file get attached my next step of application get executed.I want to get event or information that outlook is launched and file is get attached so that i can synchronize the functionality. Please let me know how we can get the file attached event in outlook. Is it possible by using other API's like CreateProcess...etc.... Pls suggest. THanks
SNI
-
Hi, I have an application which uses ShellExecuteEx function to launch Outlook and attaching file. ************************************************************ shExecInfo.fMask = SEE_MASK_NOCLOSEPROCESS ; shExecInfo.hwnd = NULL; shExecInfo.lpVerb = "open"; shExecInfo.lpFile = "outlook"; shExecInfo.lpParameters = "C:\Test.doc"; shExecInfo.lpDirectory = NULL; shExecInfo.nShow = SW_MAXIMIZE; shExecInfo.hInstApp = NULL; ShellExecuteEx(&shExecInfo); ************************************************************ I am using this functionality in my app ins such a way that once file attached i am proceeding with other functionality. But my problem is before file get attached my next step of application get executed.I want to get event or information that outlook is launched and file is get attached so that i can synchronize the functionality. Please let me know how we can get the file attached event in outlook. Is it possible by using other API's like CreateProcess...etc.... Pls suggest. THanks
SNI
To do this, I suspect you need to interface to Outlook using it's COM object model. I don't think ShellExecuteEx will cut it. This article[^] shows how to talk to Outlook using Javascript. C++ is more involved - to get anywhere, you probably want to be using
#import
with Outlook's type library - use#import "progid:Outlook.Application" auto_search
to get VC++ to generate classes for the Outlook object model. Alternatively, this article[^] tells you how to do Office Automation with COM without using#import
.Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
-
To do this, I suspect you need to interface to Outlook using it's COM object model. I don't think ShellExecuteEx will cut it. This article[^] shows how to talk to Outlook using Javascript. C++ is more involved - to get anywhere, you probably want to be using
#import
with Outlook's type library - use#import "progid:Outlook.Application" auto_search
to get VC++ to generate classes for the Outlook object model. Alternatively, this article[^] tells you how to do Office Automation with COM without using#import
.Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
-
thanks for your reply. But I want to know the event by which I come to know whether file gets attached or not so i can move further for processing. Any kind of idea will be helpful.
SNI
Yeah, it's a bit different than just launching outlook with a parameter when you use COM. Here's some VBA that will start Outlook, create and send an e-mail.
Dim o As Object 'will be an Outlook.Application Dim msg As Object 'will be a MailItem Set o = CreateObject("Outlook.Application") Set msg = o.CreateItem(0) msg.Subject = "_this is my subject_" msg.attachments.Add "_path to the attachment_" msg.body = "my message" msg.Recipients.Add "_an e-mail address_" msg.send
You can replicate that relatively easily using the
#import
approach to interfacing with Outlook.Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
-
thanks for your reply. But I want to know the event by which I come to know whether file gets attached or not so i can move further for processing. Any kind of idea will be helpful.
SNI
C++ code for the VBA I posted - note that it's pretty much a direct translation...
#import "progid:Outlook.Application" auto_search
int main(int, char**)
{
try
{
CoInitializeEx(0, COINIT_APARTMENTTHREADED);
Outlook::_ApplicationPtr ol(__uuidof(Outlook::Application));
Outlook::_MailItemPtr msg(ol->CreateItem(Outlook::olMailItem));msg->Subject = "_this is my subject_"; msg->Attachments->Add("_path to the attachment_"); // If execution gets here, the attachment's been added to msg, and you can go on and do other stuff! msg->Body = "_my message_"; msg->Recipients->Add("_an e-mail address_"); msg->Send();
}
catch (_com_error& e)
{
std::cerr << (char*)e.Description() << std::endl;
}
return 0;
}Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p