예제 #1
0
        private IntPtr AllocAttachs(out int fileCount)
        {
            fileCount = 0;
            if (attachs == null)
            {
                return(IntPtr.Zero);
            }
            if ((attachs.Count <= 0) || (attachs.Count > 100))
            {
                return(IntPtr.Zero);
            }

            Type   atype = typeof(Win32.MapiFileDesc);
            int    asize = Marshal.SizeOf(atype);
            IntPtr ptra  = Marshal.AllocHGlobal(attachs.Count * asize);

            Win32.MapiFileDesc mfd = new Win32.MapiFileDesc();
            mfd.position = -1;
            int runptr = (int)ptra;

            for (int i = 0; i < attachs.Count; i++)
            {
                string path = attachs[i] as string;
                mfd.name = Path.GetFileName(path);
                mfd.path = path;
                Marshal.StructureToPtr(mfd, (IntPtr)runptr, false);
                runptr += asize;
            }

            fileCount = attachs.Count;
            return(ptra);
        }
예제 #2
0
        private bool SaveAttachByName(string name, string savepath)
        {
            bool f      = true;
            Type fdtype = typeof(Win32.MapiFileDesc);
            int  fdsize = Marshal.SizeOf(fdtype);

            Win32.MapiFileDesc fdtmp = new Win32.MapiFileDesc();
            int runptr = (int)lastMsg.files;

            for (int i = 0; i < lastMsg.fileCount; i++)
            {
                Marshal.PtrToStructure((IntPtr)runptr, fdtmp);
                runptr += fdsize;
                if (fdtmp.flags != 0)
                {
                    continue;
                }
                if (fdtmp.name == null)
                {
                    continue;
                }

                try
                {
                    if (name == fdtmp.name)
                    {
                        if (File.Exists(savepath))
                        {
                            File.Delete(savepath);
                        }
                        File.Move(fdtmp.path, savepath);
                    }
                }
                catch (Exception)
                { f = false; error = 13; }

                try
                {
                    File.Delete(fdtmp.path);
                }
                catch (Exception)
                {}
            }
            return(f);
        }
예제 #3
0
        private void GetAttachNames(out MailAttach[] aat)
        {
            aat = new MailAttach[lastMsg.fileCount];
            Type fdtype = typeof(Win32.MapiFileDesc);
            int  fdsize = Marshal.SizeOf(fdtype);

            Win32.MapiFileDesc fdtmp = new Win32.MapiFileDesc();
            int runptr = (int)lastMsg.files;

            for (int i = 0; i < lastMsg.fileCount; i++)
            {
                Marshal.PtrToStructure((IntPtr)runptr, fdtmp);
                runptr += fdsize;
                aat[i]  = new MailAttach();
                if (fdtmp.flags == 0)
                {
                    aat[i].position = fdtmp.position;
                    aat[i].name     = fdtmp.name;
                    aat[i].path     = fdtmp.path;
                }
            }
        }
예제 #4
0
파일: MapiApi.cs 프로젝트: zaeem/FlexCollab
        private bool SaveAttachByName( string name, string savepath )
        {
            bool f = true;
            Type fdtype = typeof(Win32.MapiFileDesc);
            int fdsize = Marshal.SizeOf( fdtype );
            Win32.MapiFileDesc fdtmp = new Win32.MapiFileDesc();
            int runptr = (int) lastMsg.files;
            for( int i = 0; i < lastMsg.fileCount; i++ )
            {
                Marshal.PtrToStructure( (IntPtr) runptr, fdtmp );
                runptr += fdsize;
                if( fdtmp.flags != 0 )
                    continue;
                if( fdtmp.name == null )
                    continue;

                try
                {
                    if( name == fdtmp.name )
                    {
                        if( File.Exists( savepath ) )
                            File.Delete( savepath );
                        File.Move( fdtmp.path, savepath );
                    }
                }
                catch( Exception )
                { f = false; error = 13; }

                try
                {
                    File.Delete( fdtmp.path );
                }
                catch( Exception )
                {}
            }
            return f;
        }
예제 #5
0
파일: MapiApi.cs 프로젝트: zaeem/FlexCollab
 private void GetAttachNames( out MailAttach[] aat )
 {
     aat = new MailAttach[ lastMsg.fileCount ];
     Type fdtype = typeof(Win32.MapiFileDesc);
     int fdsize = Marshal.SizeOf( fdtype );
     Win32.MapiFileDesc fdtmp = new Win32.MapiFileDesc();
     int runptr = (int) lastMsg.files;
     for( int i = 0; i < lastMsg.fileCount; i++ )
     {
         Marshal.PtrToStructure( (IntPtr) runptr, fdtmp );
         runptr += fdsize;
         aat[i] = new MailAttach();
         if( fdtmp.flags == 0 )
         {
             aat[i].position = fdtmp.position;
             aat[i].name		= fdtmp.name;
             aat[i].path		= fdtmp.path;
         }
     }
 }
예제 #6
0
파일: MapiApi.cs 프로젝트: zaeem/FlexCollab
        private IntPtr AllocAttachs( out int fileCount )
        {
            fileCount = 0;
            if( attachs == null )
                return IntPtr.Zero;
            if( (attachs.Count <= 0) || (attachs.Count > 100) )
                return IntPtr.Zero;

            Type atype = typeof(Win32.MapiFileDesc);
            int asize = Marshal.SizeOf( atype );
            IntPtr ptra = Marshal.AllocHGlobal( attachs.Count * asize );

            Win32.MapiFileDesc mfd = new Win32.MapiFileDesc();
            mfd.position = -1;
            int runptr = (int) ptra;
            for( int i = 0; i < attachs.Count; i++ )
            {
                string path = attachs[i] as string;
                mfd.name = Path.GetFileName( path );
                mfd.path = path;
                Marshal.StructureToPtr( mfd, (IntPtr) runptr, false );
                runptr += asize;
            }

            fileCount = attachs.Count;
            return ptra;
        }