// 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()); } }
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(); }
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(); }
/// <summary> /// Send a message using mapi dll built into windows /// </summary> /// <returns></returns> private bool SendMapiMessage() { try { string subject = "Error in " + myErrorInformation.ProgramName; myErrorInformation.Steps = txtSteps.Text; Mapi myMapi = new Mapi(); myMapi.AddRecip("", myErrorInformation.SupportEmail, false); myMapi.Attach(myErrorInformation.ScreenShot); myMapi.Attach(myErrorInformation.EventLogText); myMapi.Send(subject, myErrorInformation.GetXMLMessage()); return(true); } catch (Exception ex) { //Smtp server send failed, send with a mailto link GuiException.HandleException(ex); return(false); } }