Hi guys...
I have small problem with my code

// WYSYLAMY DO HD
        Outlook.Application oApp = new Outlook.Application();
        
         //Create the new message by using the simplest approach.
        Outlook.MailItem oMsg = (Outlook.MailItem)oApp.CreateItem(Outlook.OlItemType.olMailItem);

        //Add a recipient.
        // TODO: Change the following recipient where appropriate.
        Outlook.Recipient oRecip = (Outlook.Recipient)oMsg.Recipients.Add("aaa@bb.pl");
        oRecip.Resolve();

        //Set the basic properties.
        oMsg.Subject = Environment.UserName+" is the best";
        oMsg.Body = "HURA!";
        
        //Send the message.
        oMsg.Save();
        oMsg.Send();
        
        // If you want to, display the message.
        //oMsg.Display(true);  //modal

        //Send the message.
        oMsg.Save();
        oMsg.Send();

        //Explicitly release objects.
        oRecip = null;
        oMsg = null;
        oApp = null;

whenever i run my program, i recive error

operation break. (exeption from HRESULT: 0x80004004 (E_ABORT))

an that line is marked:

Outlook.Recipient oRecip = (Outlook.Recipient)oMsg.Recipients.Add("aaa@bb.pl");

Thx for help

Ok I have modified one line:

Outlook._MailItem oMsg = (Outlook._MailItem)oApp.CreateItem(Outlook.OlItemType.olMailItem);

I added "_" before MailItem and now it works

Hmmh another problem...
Otulook doesnt send email if its not open...It doesnt start automaticaly, proggy shows message instead:

operation break. (exeption from HRESULT: 0x80004004 (E_ABORT))

and even if I send email, outlook ask me to give permission to send that email by my proggy....ho can I avoid that?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.