Outlook programming

O

Oras

Hi,

I have the following code to send am email it works well on debug but it does not work after deployment. See the error below.

private void sendEmail()
{
try
{
// calls the function to create a bmp file on a local disk

SaveAsBitmap(this, "C:\\Consular_rating.bmp");

/*(this code uses Outlook to send emails) ---------- */
OutlookApp.Application outlookApp = new Microsoft.Office.Interop.Outlook.Application();
OutlookApp._NameSpace outlookNamespace = outlookApp.GetNamespace("MAPI");
OutlookApp._MailItem outlookMail = (OutlookApp._MailItem)outlookApp.CreateItem(OutlookApp.OlIte mType.olMailItem);

//outlookMail.To = "mailto:[email protected]";
outlookMail.To = "mailto:[email protected]";
outlookMail.Subject = "Service rating";
outlookMail.Body = "Attached, please find a form that rates our services by the public.\nOpen the file to print or just view.\n\nFrom the public we serve!";

//Add an attachment.
String sSource = "C:\\Consular_rating.bmp";
String sDisplayName = "MyFirstAttachment";

int iPosition = (int)outlookMail.Body.Length + 1;
int iAttachType = (int)OutlookApp.OlAttachmentType.olByValue;
OutlookApp.Attachment oAttach = outlookMail.Attachments.Add(sSource, iAttachType, iPosition, sDisplayName);

// sends an email
outlookMail.Send();

if (MessageBox.Show(this, "Rating sent.", "Chief Directorate: Consular Services.", MessageBoxButtons.OK, MessageBoxIcon.Exclamation) == DialogResult.OK)
{
// calls the function to delete file: Consular_rating.bmp.
deleteAttachment("C:\\Consular_rating.bmp");

// closes the whole form.
this.Close();
}

}
catch (Exception ex)
{
MessageBox.Show(this, ex.Message , "Chief Directorate: Consular Services.", MessageBoxButtons.OK, MessageBoxIcon.Information);

}
}
This is an error I’m getting when trying to send from a client computer.

Unhanndle exception has occurred you application. If you click
Continue, the application will ignore this error and attemp to continue. If
You click Quit, the application will closw immediately.

Couldnot load file or assembly ‘Microsoft.Office.Interop.Outlook,
Version = 10.0.4504.0, Culture = neutral, PublicKeyToken = 31bf3856ad364e35’
or one of its dependencies. The system cannot find the file specified
 
K

Ken Slovak - [MVP - Outlook]

This forum is for custom Outlook forms, not for C# code in addins or
standalone programs. A better forum would be the program_addins forum.

What version of Outlook are you targeting, what version are you developing
on? What version of VS? Is this from a COM addin or from a standalone
program?

The error references loading Outlook 2002. Is that the version that is
running where the code is deployed? What version is on the development
machine? At least post the relevant information please.
 
O

Oras

kenslovak wrote on Fri, 15 January 2010 09:3
This forum is for custom Outlook forms, not for C# code in addins or
standalone programs. A better forum would be the program_addins forum.

What version of Outlook are you targeting, what version are you developing
on? What version of VS? Is this from a COM addin or from a standalone
program?

The error references loading Outlook 2002. Is that the version that is
running where the code is deployed? What version is on the development
machine? At least post the relevant information please.


------------------------------------------------------------ ---------

Sorry for providing less information, see the details below:

I’m targeting outlook 2007, deploying on Outlook 2007, using VS 2005, It’s from a standalone program.
 
K

Ken Slovak - [MVP - Outlook]

Something is very odd then, because the error message you showed refers to
trying to load the PIA for Outlook 2002 and failing. Check your references
and version references in your project.

What versions of Office and Outlook are installed on your development
computer?

Does running on any computer you deploy to fire this error or only on
certain machines?




"Oras" <mndawu[at]gmail[dot]com> wrote in message
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top