Beispiel #1
0
        private static IntPtr AllocOrigin(string full_name, string address)
        {
            MapiRecipDesc recipient = new MapiRecipDesc();

            recipient.ulRecipClass = MAPI.MAPI_ORIG;
            recipient.lpszName     = full_name;
            recipient.lpszAddress  = address;
            recipient.ulEIDSize    = 0;
            recipient.lpEntryID    = IntPtr.Zero;

            Type   rtype = typeof(MapiRecipDesc);
            int    rsize = Marshal.SizeOf(rtype);
            IntPtr ptrr  = Marshal.AllocHGlobal(rsize);

            Marshal.StructureToPtr(recipient, ptrr, false);
            return(ptrr);
        }
Beispiel #2
0
        private static IntPtr AllocRecips(string full_name, string address, ref uint recipcount)
        {
            Strings addresslist = Strings.FromSemiColon(address);
            Strings namelist    = Strings.FromSemiColon(full_name);

            while (namelist.Count < addresslist.Count)
            {
                namelist.Add("");
            }
            recipcount = (uint)addresslist.Count;
            MapiRecipDesc[] recipients = new MapiRecipDesc[recipcount];
            for (int i = 0; i < recipcount; i++)
            {
                MapiRecipDesc recipient = new MapiRecipDesc();
                recipients[i]          = recipient;
                recipient.ulRecipClass = MAPI.MAPI_TO;
                recipient.lpszName     = namelist[i];
                if (recipient.lpszName == "")
                {
                    recipient.lpszName = addresslist[i];
                }
                recipient.lpszAddress = "SMTP:" + addresslist[i];
                recipient.ulEIDSize   = 0;
                recipient.lpEntryID   = IntPtr.Zero;
                recipient.ulReserved  = 0;
            }

            Type   rtype      = typeof(MapiRecipDesc);
            int    simplesize = Marshal.SizeOf(rtype);
            int    rsize      = simplesize * (int)recipcount;
            IntPtr ptrr       = Marshal.AllocHGlobal(rsize);

            for (int i = 0; i < recipcount; i++)
            {
                Marshal.StructureToPtr(recipients[i], (IntPtr)((int)ptrr + simplesize * i), false);
            }
            return(ptrr);
        }