Outlook form is not always maximized
- From: "Alex" <Alex.Avid@xxxxxxxxxxxxxxxxx>
- Date: Mon, 24 Apr 2006 19:03:56 -0400
Hi,
I am hoping this is the right forum for this question; if not, please let me
know where it would be more appropriate.
I am using Outlook Object Model in C# to create a Task or an Appointment
object and pre-fill it with user information. Once all the info is setup, I
pop up the Outlook form for the user to complete, and save (or cancel) into
their outlook. This is what the code looks like:
Outlook.ApplicationClass oApp = null;
Outlook.MAPIFolder oTaskFolder = null;
Outlook.TaskItemClass oTask = null;
try {
// setup outlook objects
oApp = new Outlook.ApplicationClass();
oTaskFolder = (Outlook.MAPIFolder)oApp.GetNamespace(
"MAPI" ).GetDefaultFolder( Outlook.OlDefaultFolders.olFolderTasks);
oTask = (Outlook.TaskItemClass)oTaskFolder.Items.Add( "IPM.Task" );
// setup task properties
oTask.Subject = "Call ";
oTask.StartDate = DateTime.Now.AddDays(1);
oTask.DueDate = oTask.StartDate.AddMinutes(15);
// Reminders off by default.
oTask.ReminderSet = false;
// Set Outlook properties, if not available, create the property, then set
it.
try {
oTask.UserProperties.Item( "ACTIVITYCODE" ).Value = iCode.ToString();
}
catch {
oTask.UserProperties.Add( "ACTIVITYCODE",
Outlook.OlUserPropertyType.olNumber, System.Reflection.Missing.Value,
System.Reflection.Missing.Value );
oTask.UserProperties.Item( "ACTIVITYCODE" ).Value = iCode;
}
try {
oTask.UserProperties.Item("ACCOUNTID").Value = strAccountID;
oTask.UserProperties.Item("CONTACTID").Value = strContactID;
oTask.UserProperties.Item("OPPORTUNITYID").Value = strOpportunityID;
}
catch{}
}
oTask.Display( false );
The problem is that sometimes, if Outlook is minimized, the form doesn't
"pop-up" but stays minimized, and flashes in the task bar. I need to force
it to always pop-up. Using Windows API is not helping:
// attempt to locate outlook window and focus on it.
string sText = oTask.Subject + " - Task ";
IntPtr hwnd = FindWindow( null, sText );
ShowWindow( hwnd, 9);
Is there anything I can do to guarantee that the window will be placed on
top and activated?
TIA
Alex
.
- Follow-Ups:
- Re: Outlook form is not always maximized
- From: Ken Slovak - [MVP - Outlook]
- Re: Outlook form is not always maximized
- Prev by Date: Re: HOWTO: Remove parenthesis for phone numbers in Outlook
- Next by Date: Re: HOWTO: Remove parenthesis for phone numbers in Outlook
- Previous by thread: Re: HOWTO: Remove parenthesis for phone numbers in Outlook
- Next by thread: Re: Outlook form is not always maximized
- Index(es):
Relevant Pages
|
Loading