Benutzer mit den meisten Antworten
Problem beim E-Mail generieren

Frage
-
Hallo zusammen
Ich bin gerade dabei ein Mail, im Outlook, via C#, zu erstellen. Als Hilfe habe ich mir die MS How-To Anleitung (Link: http://msdn.microsoft.com/de-de/library/ms269113.aspx) genommen. Naja, die funktioniert auch irgendwie, das Mail inkl. Anhang wird erstellt, jedoch nicht verschickt. Es landet immer im Ordner Postausgang und bleibt auch dort. Es spielt dabei keine Rolle ob Outlook gestartet ist oder nicht. Manuelle Mails hingegen funktionieren. Zudem sind die Anforderungen auch erfüllt (OutLooker 2013).
Gruss Gezim95
- Bearbeitet Gezim95 Sonntag, 14. September 2014 18:37
Antworten
-
du kannst da noch eine
try
{
code blabla...
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
}drumrum bastel, evtl. wird dir ne fehlermeldung angezeigt.
bzw. ist der empfänger auch vorhanden?
bei mir läuft der code:
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Xml.Linq; using Outlook = Microsoft.Office.Interop.Outlook; using Office = Microsoft.Office.Core; namespace OutlookAddIn1 { public partial class ThisAddIn { private void ThisAddIn_Startup(object sender, System.EventArgs e) { CreateMailItem(); } private void CreateMailItem() { Outlook.MailItem mailItem = (Outlook.MailItem) this.Application.CreateItem(Outlook.OlItemType.olMailItem); mailItem.Subject = "This is the subject"; mailItem.To = "someone@example.com"; mailItem.Body = "This is the message."; mailItem.Importance = Outlook.OlImportance.olImportanceLow; mailItem.Display(false); mailItem.Send (); } private void ThisAddIn_Shutdown(object sender, System.EventArgs e) { } #region VSTO generated code /// <summary> /// Required method for Designer support - do not modify /// the contents of this method with the code editor. /// </summary> private void InternalStartup() { this.Startup += new System.EventHandler(ThisAddIn_Startup); this.Shutdown += new System.EventHandler(ThisAddIn_Shutdown); } #endregion } }
Alle Antworten
-
Hallo sleepy007
Outlook.Application oOutlook = new Outlook.Application(); Outlook.MailItem mailItem = (Outlook.MailItem) oOutlook.CreateItem(Outlook.OlItemType.olMailItem); mailItem.Subject = "This is the subject"; mailItem.To = "someone@example.com"; mailItem.Body = "This is the message."; mailItem.Importance = Outlook.OlImportance.olImportanceLow; mailItem.Display(true);
Das Mail soll aber nicht automatisch gesendet werden. Der Benutzer muss dann selber auf den Send Button klicken.
Gruss Gezim95
Gezim
-
du kannst da noch eine
try
{
code blabla...
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
}drumrum bastel, evtl. wird dir ne fehlermeldung angezeigt.
bzw. ist der empfänger auch vorhanden?
bei mir läuft der code:
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Xml.Linq; using Outlook = Microsoft.Office.Interop.Outlook; using Office = Microsoft.Office.Core; namespace OutlookAddIn1 { public partial class ThisAddIn { private void ThisAddIn_Startup(object sender, System.EventArgs e) { CreateMailItem(); } private void CreateMailItem() { Outlook.MailItem mailItem = (Outlook.MailItem) this.Application.CreateItem(Outlook.OlItemType.olMailItem); mailItem.Subject = "This is the subject"; mailItem.To = "someone@example.com"; mailItem.Body = "This is the message."; mailItem.Importance = Outlook.OlImportance.olImportanceLow; mailItem.Display(false); mailItem.Send (); } private void ThisAddIn_Shutdown(object sender, System.EventArgs e) { } #region VSTO generated code /// <summary> /// Required method for Designer support - do not modify /// the contents of this method with the code editor. /// </summary> private void InternalStartup() { this.Startup += new System.EventHandler(ThisAddIn_Startup); this.Shutdown += new System.EventHandler(ThisAddIn_Shutdown); } #endregion } }
-
Hallo Gezim,
das Verhalten ist ganz normal in Outlook.
mailItem.Send() bewirkt lediglich das die Email in den Postausgang gelegt wird und das funktioniert ja offensichtlich. Das ist eine Einstellung in Outlook selber. Es gibt unter Optionen - Erweitert ein Häkchen "Bei bestehender Verbindung sofort senden"... dieses muss gesetzt sein.
Gruß
Jens