El sistema Office de Microsoft es el mas popular del menudo y me atrevo a decir el unico sistema administrativo que nos da todo o casi todo lo que deseamos para hacer nuestro trabajo en la oficina, pero que sucede cuando tenemos un sistema ajeno este paquete?, imegenemos el siguiente esceneario:
suponga que usted es un desarrollador en tecnologia .NET y esta en un proceso para anexar a un calendario alguna tarea importante que su sistema genera y desea que no se pase por alto por que es de suma importancia que la realicen. Mediante esta pequeña clase podemos hacer esto de una forma simple.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Outlook = Microsoft.Office.Interop.Outlook;
namespace SISTEMA_TDM.Clases
{
class clsCalendarioOutLook
{
public string ASUNTO {get;set;}
public string TEMA {get;set;}
public string FECHA { get; set; }
public void ANEXAR_CITA()
{
Outlook.Application outlookApp = new Outlook.Application();
Outlook.AppointmentItem oAppointment = (Outlook.AppointmentItem)outlookApp.CreateItem(Outlook.OlItemType.olAppointmentItem);
oAppointment.Subject = TEMA;
oAppointment.Body = ASUNTO;
oAppointment.Location = Properties.Settings.Default.DEPTARTAMENTO;
// fecha de inicio
oAppointment.Start = Convert.ToDateTime(FECHA);
// fecha final
oAppointment.End = Convert.ToDateTime(FECHA).AddMinutes(60);
oAppointment.ReminderSet = true;
oAppointment.ReminderMinutesBeforeStart = 15;
oAppointment.ReminderPlaySound = true;
//importancia alta
oAppointment.Importance = Outlook.OlImportance.olImportanceHigh;
/* OlBusyStatus is enum with following values:
olBusy-ocupado
olFree -libre
olOutOfOffice-fuera de la oficina
olTentative -tentativo
*/
oAppointment.BusyStatus = Microsoft.Office.Interop.Outlook.OlBusyStatus.olBusy;
oAppointment.Save();
}
public static void ANEXAR_CONTACTO(string nickname,string correo,string direccion,string telefono,string cliente)
{
Outlook.Application CONTACTO = new Outlook.Application();
Outlook.ContactItem _contacto = (Outlook.ContactItem)CONTACTO.CreateItem(Outlook.OlItemType.olContactItem);
try
{
_contacto.FullName = nickname;
_contacto.PrimaryTelephoneNumber = telefono;
_contacto.CompanyName = cliente;
_contacto.Email1Address = correo;
_contacto.BusinessAddress = direccion;
_contacto.Save();
}
catch (Exception ex)
{
throw ex;
}
}
public static void ANEXAR_TAREAS(string mtarea)
{
Outlook.Application tarea = new Outlook.Application();
Outlook.TaskItem _tarea= (Outlook.TaskItem)tarea.CreateItem(Outlook.OlItemType.olTaskItem);
_tarea.Subject=mtarea;
_tarea.Save();
}
}
}
suponga que usted es un desarrollador en tecnologia .NET y esta en un proceso para anexar a un calendario alguna tarea importante que su sistema genera y desea que no se pase por alto por que es de suma importancia que la realicen. Mediante esta pequeña clase podemos hacer esto de una forma simple.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Outlook = Microsoft.Office.Interop.Outlook;
namespace SISTEMA_TDM.Clases
{
class clsCalendarioOutLook
{
public string ASUNTO {get;set;}
public string TEMA {get;set;}
public string FECHA { get; set; }
public void ANEXAR_CITA()
{
Outlook.Application outlookApp = new Outlook.Application();
Outlook.AppointmentItem oAppointment = (Outlook.AppointmentItem)outlookApp.CreateItem(Outlook.OlItemType.olAppointmentItem);
oAppointment.Subject = TEMA;
oAppointment.Body = ASUNTO;
oAppointment.Location = Properties.Settings.Default.DEPTARTAMENTO;
// fecha de inicio
oAppointment.Start = Convert.ToDateTime(FECHA);
// fecha final
oAppointment.End = Convert.ToDateTime(FECHA).AddMinutes(60);
oAppointment.ReminderSet = true;
oAppointment.ReminderMinutesBeforeStart = 15;
oAppointment.ReminderPlaySound = true;
//importancia alta
oAppointment.Importance = Outlook.OlImportance.olImportanceHigh;
/* OlBusyStatus is enum with following values:
olBusy-ocupado
olFree -libre
olOutOfOffice-fuera de la oficina
olTentative -tentativo
*/
oAppointment.BusyStatus = Microsoft.Office.Interop.Outlook.OlBusyStatus.olBusy;
oAppointment.Save();
}
public static void ANEXAR_CONTACTO(string nickname,string correo,string direccion,string telefono,string cliente)
{
Outlook.Application CONTACTO = new Outlook.Application();
Outlook.ContactItem _contacto = (Outlook.ContactItem)CONTACTO.CreateItem(Outlook.OlItemType.olContactItem);
try
{
_contacto.FullName = nickname;
_contacto.PrimaryTelephoneNumber = telefono;
_contacto.CompanyName = cliente;
_contacto.Email1Address = correo;
_contacto.BusinessAddress = direccion;
_contacto.Save();
}
catch (Exception ex)
{
throw ex;
}
}
public static void ANEXAR_TAREAS(string mtarea)
{
Outlook.Application tarea = new Outlook.Application();
Outlook.TaskItem _tarea= (Outlook.TaskItem)tarea.CreateItem(Outlook.OlItemType.olTaskItem);
_tarea.Subject=mtarea;
_tarea.Save();
}
}
}
como veras el codigo es algo muy compacto gracias ala interaccion que existe entre Outlook y .Net, espero que les sirva.
Comentarios
Publicar un comentario