예제 #1
0
        //		public void Send_textWithCC(string to,string subject,string textMail,string textCCMailAddress )
        //		{
        //
        //		}
        public void Send_text(string to, string subject, string textMail)
        {
            try
            {
                ma1 = new Mapi();
                ma1.AddRecip(to, null, false);

                /*
                 * if( textCC.Text != null )
                 * {
                 *      if( textCC.Text.Length > 0 )
                 *              ma.AddRecip( textCC.Text, null, true );
                 * }
                 */
                //lblStatus.Text="Current Status :  Sending Message";
                if (!ma1.Send(subject, textMail))
                {
                    MessageBox.Show(this, "MAPISendMail failed! " + ma1.Error(), "Send Mail", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }

                ma1.Reset();
                //this.Close();
            }
            catch (Exception exp)
            {
                MessageBox.Show(exp.Message.ToString());
            }
        }
예제 #2
0
        static void Main(string[] args)
        {
            // Mapi-Instanz erzeugen
            Mapi mapi = new Mapi();

            // Logon in MAPI. Sie können den aktuellen
            // Benutzer einloggen, indem Sie IntPtr.Zero übergeben.
            // Wollen Sie einen spezifischen Benutzer einloggen,
            // können Sie ein Token über die API-Funktion LogonUser
            // erzeugen und dessen Handle übergeben.
            if (mapi.Logon(IntPtr.Zero) == false)
            {
                Console.WriteLine("Der Login in MAPI ist fehlgeschlagen: " + mapi.Error());
                return;
            }

            // Empfänger hinzufügen
            string mailAddress = "*****@*****.**";

            mapi.AddRecip(mailAddress, null, false);

            // Datei anfügen
            string fileName = Path.Combine(Application.StartupPath, "dontpanic.gif");

            mapi.Attach(fileName);

            // Mail senden
            string subject = "Party";
            string message = "Hallo Zaphod, hast du Lust auf eine Party im Restaurant " +
                             "am Ende der Galaxis?";

            if (mapi.Send(subject, message))
            {
                Console.WriteLine("E-Mail erfolgreich versendet");
            }
            else
            {
                Console.WriteLine("Das Senden ist fehlgeschlagen: {0}", mapi.Error());
            }

            // Aus MAPI ausloggen
            mapi.Logoff();

            Console.WriteLine("Beenden mit Return");
            Console.ReadLine();
        }
예제 #3
0
        private void buttonSend_Click(object sender, System.EventArgs e)
        {
            ma.Attach(this.filename);
            lblStatus.Text = "Current Status :  Adding Recipients";
            ma.AddRecip(textTO.Text, null, false);
            if (textCC.Text != null)
            {
                if (textCC.Text.Length > 0)
                {
                    ma.AddRecip(textCC.Text, null, true);
                }
            }
            lblStatus.Text = "Current Status :  Sending Message";
            if (!ma.Send(textSubject.Text, textMail.Text))
            {
                MessageBox.Show(this, "MAPISendMail failed! " + ma.Error(), "Send Mail", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }

            ma.Reset();
            this.Close();
        }