none
Problem beim E-Mail generieren RRS feed

  • 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
    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
        }
    }
    

    • Bearbeitet sleepy007 Montag, 15. September 2014 13:58
    • Als Antwort markiert Gezim95 Montag, 15. September 2014 14:07
    • Tag als Antwort aufgehoben Gezim95 Montag, 15. September 2014 14:08
    • Als Antwort markiert Gezim95 Montag, 15. September 2014 14:08
    Montag, 15. September 2014 13:54

Alle Antworten

  • Moin,

    ohne Programmcode ist Hilfe sehr schwierig.

    Vielleicht reicht es auch einfach wenn Du noch ein

    mailItem.Send()

    ran hängst.

    Grüße

    Montag, 15. September 2014 05:09
  • 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

    Montag, 15. September 2014 06:18
  • Hallo nochmal

    Kann es etw. mit dem

    mailItem.Importance = Outlook.OlImportance.olImportanceLow;

    zu tun haben bzw. mit dem Low


    Gezim

    Montag, 15. September 2014 06:32
  • Und was genau ist Dein Problem?
    Montag, 15. September 2014 13:21
  • Nein mit dem olImportanceLow hat es nichts zu tun. Die E-Mails bleiben immer  im Ordner Postausgang und werden nicht versandt. Das ist mein Problem.


    Gezim

    Montag, 15. September 2014 13:29
  • Das die Emails nicht versendet werden ist Dein Problem?
    Montag, 15. September 2014 13:31
  • Genau

    Gezim

    Montag, 15. September 2014 13:33
  • Und was hält Dich davon ab, an Deinen Code noch

    mailItem.Send()

    daran zu hängen?
    Montag, 15. September 2014 13:35
  • Auch mit dem mailItem.Send() funktioniert es leider noch nicht.
    • Bearbeitet Gezim95 Montag, 15. September 2014 13:48
    Montag, 15. September 2014 13:47
  • 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
        }
    }
    

    • Bearbeitet sleepy007 Montag, 15. September 2014 13:58
    • Als Antwort markiert Gezim95 Montag, 15. September 2014 14:07
    • Tag als Antwort aufgehoben Gezim95 Montag, 15. September 2014 14:08
    • Als Antwort markiert Gezim95 Montag, 15. September 2014 14:08
    Montag, 15. September 2014 13:54
  • 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 

    Montag, 15. September 2014 17:10