c# - New Instance of Outlook not being recognized in solution -


I have a code that is used to create a new appointment for Outlook C #

Unfortunately, when I set a new instance of Outlook

  Outlook.Application outlookApp = New Outlook.Application (); // The new approach creates the app  

"outlookApp" is not being recognized in the next line, (Error Error 24 Field Beginner Non-Static Field, Method, or Property 'Not Referring Outlook.AppointmentItem oAppointment = (Outlook.AppointmentItem) outlookApp.CreateItem (Outlook.OlItemType.olAppointmentItem);

Complete code for reference.

  Outlook.Applying OutlookApp = new Outlook .Application (); // New Outlook App creates Outlook AppointmentItem oAppointment = (Outlook.AppointmentItem) outlookApp.CreateItem (Outlook.OlItemType.olAppointmentItem); // Creates a new placement appointment. Subject = "Vacation Request" + Name; // Set topic oAppointment.Body = ""; // Set the Body / Submit the details of the contact form below the appointment. Location = "enix desk!"; // Set the location oAppointment.Start = Convert.ToDateTime (Notes); // Date of date of start date is required that the user enters the DATEFROM oAppointment.End = Convert.ToDateTime (Notes); // Date of the date of expiration is required that the user enters the data appointment. Reinderset = true; // Set a reminder appointment. Rimindarwindsbinstrat = 15; // Reminder time appointment. Importance = Outlook Olines .ol import // Placement importance oAppointment.BusyStatus = Outlook.OlBusyStatus.olBusy; OAppointment.Save (); Outlook.MailItem mailItem = oAppointment.ForwardAsVcal (); // which is sending e-mail mail item. St.OnBloffAffnonym = Name Input; // To send an email address, mailItem.To = "mailto: me@decodedsolutions.co.uk" & gt; Me@decodedsolutions.co.uk; // send mailItem.Send ();  

Any ideas?

Trying to say error

move the initiator into a method .

For an example,

Comments