CoreLAb OracleConnection lets MAPI die

CoreLAb OracleConnection lets MAPI die

Postby tosch » 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:
Code: Select all
    private void button1_Click(object sender, EventArgs e)
    {
     // _Connection.Open();
      Send("SMTP:Enter@MailAdress.com", "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 < recpts.Length; i++)
      {
        Marshal.StructureToPtr(recpts[i], (IntPtr)runptr, false);
        runptr += rsize;
      }
      return ptrr;
    }

    public void Send(string receiver, string subject, string messageBody)
    {
      MapiRecipDesc origin = new MapiRecipDesc();
      MapiRecipDesc recip = new MapiRecipDesc();
      recip.Address = receiver;
      recip.RecipClass = 1;

      MapiMessage message = new MapiMessage();
      try
      {

        message.Originator = AllocOrigin(origin);

        message.RecipCount = 1;
        message.Recips = AllocRecips(recip);

        message.FileCount = 0;
        message.Files = IntPtr.Zero;

        message.Subject = subject;
        message.NoteText = messageBody;

        Text = MAPISendMail(IntPtr.Zero, IntPtr.Zero, message, 1, 0).ToString();
      }
      finally
      {
        Marshal.DestroyStructure(message.Originator, typeof(MapiRecipDesc));
        Marshal.FreeHGlobal(message.Originator);

        Marshal.DestroyStructure(message.Recips, typeof(MapiRecipDesc));
        Marshal.FreeHGlobal(message.Recips);
      }
    }

If you now click on the button you will be ask by Outlook to allow to send a mail. Press No -> 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: Select all
// _Connection.Open();

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
tosch
 
Posts: 10
Joined: Thu 28 Dec 2006 11:47

Postby Alexey » Tue 09 Jan 2007 07:34

Please check if you have same problems with Direct=true in ConnectionString.
Alexey
 
Posts: 2756
Joined: Mon 13 Mar 2006 07:43

Direct works, but...

Postby tosch » Tue 09 Jan 2007 10:57

That works, but unfortunately i have to use the oracle client. (Our Delphi client works with the same constellation)
tosch
 
Posts: 10
Joined: Thu 28 Dec 2006 11:47

Postby Alexey » Wed 10 Jan 2007 07:55

We are investigating this problem.
You will be notified on results as soon as possible.
Alexey
 
Posts: 2756
Joined: Mon 13 Mar 2006 07:43

Postby Alexey » Thu 11 Jan 2007 07:30

This problem might be connected with loading unmanaged dll MAPI and Oracle client. Unfortunately, we cannot reproduce it.
Please specify your operating system, hardware architecture, paths to dlls.
Last edited by Alexey on Fri 12 Jan 2007 07:37, edited 1 time in total.
Alexey
 
Posts: 2756
Joined: Mon 13 Mar 2006 07:43

Postby tosch » Thu 11 Jan 2007 16:05

Here is the requested information:
Betriebssystemname Microsoft Windows XP Professional
Version 5.1.2600 Service Pack 2 Build 2600
Betriebssystemhersteller Microsoft Corporation
Systemname PC-TS
Systemhersteller System Manufacturer
Systemmodell System Name
Systemtyp X86-basierter PC
Prozessor x86 Family 15 Model 2 Stepping 5 GenuineIntel ~3000 Mhz
Prozessor x86 Family 15 Model 2 Stepping 5 GenuineIntel ~3000 Mhz
BIOS-Version/-Datum Award Software, Inc. ASUS P4PE ACPI BIOS Revision 1007, 10.11.2003
SMBIOS-Version 2.3
Windows-Verzeichnis C:\WINNT
Systemverzeichnis C:\WINNT\system32
Startgerät \Device\HarddiskVolume1
Gebietsschema Deutschland
Hardwareabstraktionsebene Version = "5.1.2600.2180 (xpsp_sp2_rtm.040803-2158)"
Benutzername AQUILANT\ts
Zeitzone Westeuropäische Normalzeit
Gesamter realer Speicher 1.024,00 MB
Verfügbarer realer Speicher 155,25 MB
Gesamter virtueller Speicher 2,00 GB
Verfügbarer virtueller Speicher 1,96 GB
Größe der Auslagerungsdatei 2,37 GB
Auslagerungsdatei D:\pagefile.sys
Oracle Client 10.2g

It seems that the problem only apears with the Oracle 10 Client.
I will sent you a working test project by PM

Regards
Torsten
tosch
 
Posts: 10
Joined: Thu 28 Dec 2006 11:47

Postby tosch » Thu 11 Jan 2007 16:07

Sorry PM is disabled :(
tosch
 
Posts: 10
Joined: Thu 28 Dec 2006 11:47

Postby tosch » Thu 11 Jan 2007 16:28

I sent a mail to support at crlab dot com with a complete project maybe you can reprodure it now (with an Oracle 10.2g Client). It works well with Oracle client 9.2.

Regards
Torsten
tosch
 
Posts: 10
Joined: Thu 28 Dec 2006 11:47

Postby Alexey » Fri 12 Jan 2007 07:40

Your project is received and now is being investigated.
Look forward to hearing from us soon.
Alexey
 
Posts: 2756
Joined: Mon 13 Mar 2006 07:43

Postby tosch » Mon 05 Feb 2007 08:23

Are there any news about this problem?
tosch
 
Posts: 10
Joined: Thu 28 Dec 2006 11:47

Postby Alexey » Mon 05 Feb 2007 15:33

Unfortunately, we cannot reproduce the problem on our end.
Maybe it has to do something with loading unmanaged dll MAPI and Oracle client. Maybe it is Windows or Oracle client version dependent. Maybe the paths where assemblies reside are different.
Do you have this problem on another PC?
Last edited by Alexey on Wed 04 Apr 2007 08:48, edited 1 time in total.
Alexey
 
Posts: 2756
Joined: Mon 13 Mar 2006 07:43

Postby tosch » Tue 06 Feb 2007 14:01

This problem happens on all teseted machines with Oracle 10.2 Client and Framework 2.0
tosch
 
Posts: 10
Joined: Thu 28 Dec 2006 11:47

Postby Alexey » Wed 07 Feb 2007 17:20

We need some time for further investigation.
Thanks for your patience.
Alexey
 
Posts: 2756
Joined: Mon 13 Mar 2006 07:43

Postby drzemik » Wed 28 Mar 2007 14:50

I have the same problem.

It only occures on machine with clean instalation of OracleClient 10.2.

If machine has OracleClient 9.2 or it was upgraded from 9.2 to 10.2 - it works correctly. And also problem occures only if application connects to database.
drzemik
 
Posts: 4
Joined: Wed 28 Mar 2007 14:47

Postby Alexey » Thu 29 Mar 2007 06:26

Please send me your project to reproduce the problem, including all third-parties (if any).
Use e-mail address provided in the Readme file.
Alexey
 
Posts: 2756
Joined: Mon 13 Mar 2006 07:43

Next

Return to dotConnect for Oracle