none
Cannot convert elm file into Microsoft.Office.Interop.Outlook.MailItem RRS feed

  • Question

  • Good day,

    I made a software wich connect to a pop server and download message in elm format.

    I want to contert it into a Microsoft.Office.Interop.Outlook.MailItem. I can open my elm file from explorer without any problem, but in my program, I get this error in the line Mail = Outl.CreateItemFromTemplate(Fichier, ClsHotline.RepTmp.TrimEnd("\")) :

    "We can't open '....\....elm'. It's possible the file is already open, or you don't have permission to open it."

    Here is my code :

    (connect to pop server with openpop and get my email)

     EmailRecu.Save(File)
                            Dim FileAcl As New System.Security.AccessControl.FileSecurity
                            FileAcl.AddAccessRule(New System.Security.AccessControl.FileSystemAccessRule("Tout le monde", Security.AccessControl.FileSystemRights.FullControl, Security.AccessControl.AccessControlType.Allow))
                            File.SetAccessControl(FileAcl)
                            File.Attributes = IO.FileAttributes.Normal
                            File.SetAccessControl(FileAcl)

    (disconnect from pop serveur)

    Dim Mail As Microsoft.Office.Interop.Outlook.MailItem = Nothing

     Dim OutlkOuvert As Boolean = False
                    Dim procs() As Process = Process.GetProcessesByName("Outlook")
                    If procs.Count > 0 Then
                        OutlkOuvert = True
                    End If
                    Dim Outl As New Microsoft.Office.Interop.Outlook.Application
                    Mail = Outl.CreateItemFromTemplate(Fichier, ClsHotline.RepTmp.TrimEnd("\"))
                    If Not OutlkOuvert Then
                        Outl.Quit()
                    End If
                    Outl = Nothing

    Thank you in advance.


    pieret

    Friday, March 3, 2017 6:43 AM

All replies

  • I tried Mail = Outl.CreateItemFromTemplate(Fichier) instead of Mail = Outl.CreateItemFromTemplate(Fichier, ClsHotline.RepTmp.TrimEnd("\")), still got the same proglem.

    pieret

    Friday, March 3, 2017 6:44 AM