Hi. Please help, i am trying to program a simple email application for my window pc using c#. I keep getting "NullReferenceException was unhandled" at line 37 when i debug.
using System;
using System.Linq;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.IO;
using System.Net;
using Microsoft.WindowsMobile.PocketOutlook;
using System.Web.Services;
namespace SmartDeviceProject1
{
public partial class Form1 : Form
{
OutlookSession aSession;
public Form1()
{
InitializeComponent();
aSession = new OutlookSession();
}
private void btnAlert_Click(object sender, EventArgs e)
{
EmailAccount myAcct = aSession.EmailAccounts["POP3"];
EmailMessage mesg = new EmailMessage();
mesg.BodyText = "Hello.";
Recipient recv = new Recipient("xxx", "xxx@hotmail.com");
mesg.To.Add(recv);
myAcct.Send(mesg);
MessageBox.Show("Done!", "Notice");
this.btnAlert.Enabled = false;
}
}
}