CoreLAb OracleConnection lets MAPI die
Posted: Fri 05 Jan 2007 22:38
Hi,
i have a big problem! I use MAPI (via Outlook) to send mails - that works fine, but when i use the CoreLab OracleConnection and i call Open on this connection MAPI does not longer wok until i restart the Application.
HEre is the way to reprodure it:
1. Craete a new Project "Windows Application"
2. Drop a Button on the From
3. Add the following Code to the Click event:
4. Add the following Code to the class:
If you restart your Application the Outlook dialog no more comes up and the result always is 2 (= MAPI_E_FAILURE)
Any Ideas how i can fix that?
Thanks
Torsten
i have a big problem! I use MAPI (via Outlook) to send mails - that works fine, but when i use the CoreLab OracleConnection and i call Open on this connection MAPI does not longer wok until i restart the Application.
HEre is the way to reprodure it:
1. Craete a new Project "Windows Application"
2. Drop a Button on the From
3. Add the following Code to the Click event:
Code: Select all
private void button1_Click(object sender, EventArgs e)
{
// _Connection.Open();
Send("SMTP:[email protected]", "Test", "Text");
}
4. Add the following Code to the class:
Code: Select all
[StructLayout(LayoutKind.Sequential, CharSet = System.Runtime.InteropServices.CharSet.Ansi)]
public class MapiMessage
{
public int Reserved = 0;
public string Subject = string.Empty;
public string NoteText = string.Empty;
public string MessageType = null;
public string DateReceived = null;
public string ConversationID = null;
public int Flags = 0;
public IntPtr Originator = IntPtr.Zero;
public int RecipCount = 0;
public IntPtr Recips = IntPtr.Zero;
public int FileCount = 0;
public IntPtr Files = IntPtr.Zero;
}
[StructLayout(LayoutKind.Sequential, CharSet = System.Runtime.InteropServices.CharSet.Ansi)]
public class MapiRecipDesc
{
public int Reserved = 0;
public int RecipClass = 0;
public string Name = null;
public string Address = null;
public int EntryIDSize = 0;
public IntPtr EntryID = IntPtr.Zero;
}
[DllImport("MAPI32.DLL", CharSet = CharSet.Ansi)]
private static extern int MAPISendMail(IntPtr lhSession, IntPtr hwndParent,
MapiMessage lpMessage, int flFlags, int ulReserved);
private static IntPtr AllocOrigin(MapiRecipDesc origin)
{
Type rtype = typeof(MapiRecipDesc);
int rsize = Marshal.SizeOf(rtype);
IntPtr ptro = Marshal.AllocHGlobal(rsize);
Marshal.StructureToPtr(origin, ptro, false);
return ptro;
}
private static IntPtr AllocRecips(params MapiRecipDesc[] recpts)
{
if (recpts.Length == 0)
return IntPtr.Zero;
Type rtype = typeof(MapiRecipDesc);
int rsize = Marshal.SizeOf(rtype);
IntPtr ptrr = Marshal.AllocHGlobal(recpts.Length * rsize);
int runptr = (int)ptrr;
for (int i = 0; i Result = 26 (see Windows caption)
(I know that this is not enough code to send a mail, but it is enough to show the problem)
Now remove the cmment from
[code]// _Connection.Open();
Any Ideas how i can fix that?
Thanks
Torsten