Showing posts with label outlook. Show all posts
Showing posts with label outlook. Show all posts

Thursday, December 10, 2009

Outlook Emailer

Problem: I want to send email with important information to my 450 friends at one time. The email should be in HTML format, with appropriate font style, size, and color, and some images.

Solution: Let's capitalize MS Office Outlook and creating an application utilizing
Visual Studio Tools for Office. Visual Studio Tools for Office is bundled with Visual Studio 2008. Thus, installing the latter gives the developer access to the former. Now, open a new Windows Forms Application project then add

  • Microsoft.VisualStudio.Tools.Applications.Runtime.v9.0
  • Office
  • Microsoft.Office.Interop.Outlook
as References. Next, design the form.


Then, add code to the Send button. First things first:

using Microsoft.VisualStudio.Tools.Applic
ations.Runtime;
using Outlook = Microsoft.Office.Interop.Outlook;
using Office = Microsoft.Office.Core;

Then

private void btnSend_Click(object sender, EventArgs e)
{
try {
Outlook.Application _app = new Outlook.Application();
Outlook.MailItem mailItem = _app.CreateItem(Outlook.OlItemType.olMailItem) as Outlook.MailItem;
mailItem.Subject = txtSubject.Text;
mailItem.BodyFormat = Microsoft.Office.Interop.Outlook.OlBodyFormat.olFormatHTML;
mailItem.Importance = Microsoft.Office.Interop.Outlook.OlImportance.olImportanceHigh;
mailItem.HTMLBody = txtMessage.Text;
mailItem.BCC = txtTo.Text;
mailItem.Display(false);
mailItem.Send();
MessageBox.Show("Message has been sent!");
}
catch (Exception ex) {
MessageBox.Show(ex.Message);
}
}

Thursday, November 5, 2009

MS Outlook PS #1: Error using Comma as Email Address Separator

Problem:

Receiving error message when using comma as email address separator.

Solution:

Microsoft Office Outlook 2003 and Microsoft Office Outlook 2007 uses, by default, semi-colons to separate email addresses.

You can configure Outlook to recognize the comma as a valid e-mail address separator as follows:

  1. On the Tools menu, click Options....
  2. On the General tab, click E-Mail Options
  3. Click Advanced E-Mail Options
  4. Under When sending a message click to select the Allow comma as address separator check box.
Note: You can still use semi-colon (;) as email address separator.