Outlook programming

Status
Not open for further replies.
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:legalisation@dirco.gov.za";

outlookMail.To = "mailto:ngomanem@dirco.gov.za";

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.

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

news:ODY4xMblKHA.2160@TK2MSFTNGP02.phx.gbl...
> 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:legalisation@dirco.gov.za";
> outlookMail.To = "mailto:ngomanem@dirco.gov.za";
> 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

>
 
O

Oras

kenslovak wrote on Fri, 15 January 2010 09:37
> 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.

> >

>

> "Oras" <mndawu[at]gmail[dot]com> wrote in message
> news:ODY4xMblKHA.2160@TK2MSFTNGP02.phx.gbl...
> > 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:legalisation@dirco.gov.za";
> > outlookMail.To = "mailto:ngomanem@dirco.gov.za";
> > 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
> >


------------------------------------------------------------ -------
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

news:eT3cO5$lKHA.5040@TK2MSFTNGP06.phx.gbl...

<snip>
> 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.

>
 
Status
Not open for further replies.
Similar threads
Thread starter Title Forum Replies Date
R Programming Web Outlook Access Outlook VBA and Custom Forms 3
S Programming Outlook from MS Access (Inbox) Outlook VBA and Custom Forms 1
L Duplicate calendar entries in Outlook 365 Using Outlook 2
V Outlook 2021 Can anyone explain why my Outlook views keep changing?! Using Outlook 2
AlphonseG Outlook 365 Outlook Crashes on setting SaveSentMessageFolder Outlook VBA and Custom Forms 2
S Outlook 2021 How to customize colors Outlook 2021 & Office 2021 on PC Using Outlook 0
D Outlook 2007 Recovering E-Mails Using Outlook 0
G Stop Outlook 365 adding meetings to calendar Using Outlook 0
HarvMan Using Emojis in Outlook 365 Using Outlook 3
T Outlook 2019 Not Using Auto Compete After Deletion of 365 Using Outlook 1
D Gmail mail is being delivered to a different email inbox in Outlook App 2021 Using Outlook 2
Albert McCann Outlook 2021 Outlook Display of HTML Email from two senders is glitchy Using Outlook 0
richardwing Outlook 365 VBA to access "Other Actions" menu for incoming emails in outlook Outlook VBA and Custom Forms 0
J Unable to delete folders in Outlook 2019 / Windows Using Outlook 1
K Outlook for Mac problems Using Outlook 0
D Outlook app 2021 & iCloud PST issues Using Outlook 2
M c# vsto Outlook.ApplicationEvents_11_NewMailEx Outlook VBA and Custom Forms 1
J Event/Meeting in Outlook Does Not Align with SharePoint Calendar Using Outlook 5
Christopher M Is it me, or is Outlook 365 BUGGY? Using Outlook 3
U Outlook on the iPhone cannot approve filtered Emails Using Outlook 0
J GoDaddy migrated to Office365 - Outlook Wont Add Account Exchange Server Administration 21
K Outlook 365 After migrating to Outlook 365, some contacts display in emails with prefixes Using Outlook 1
J Outlook Rules VBA Run a Script - Multiple Rules Outlook VBA and Custom Forms 0
Horsepower Cannot delete gmail in iPhone Outlook outbox Using Outlook 1
F Outlook 2019 Outlook 2019 Add and Sync to New computer Comcast server Using Outlook 2
M Understanding Outlook Identities Using Outlook 1
kburrows Outlook or Phone Combining Contacts? Using Outlook 0
P Outlook 2013 search no longer works Using Outlook 2
M Accessing ALL Outlook contact fields Outlook VBA and Custom Forms 3
C Outlook (desktop app for Microsoft365) restarts every time I save my VBA? Using Outlook 0
R MailTips and older Outlook versions Using Outlook 0
A iCloud Outlook Add In is causing Outlook 2021 to crash and got disabled Using Outlook 9
C How to import Outlook calendar? Using Outlook 1
HarvMan Outlook 365 loses "outlook.com" exchange server settings Using Outlook 1
HarvMan Outlook.com Account Using Outlook 3
D Office 365 Outlook desktop app prompts for all account passwords on startup Using Outlook 6
D Alerts in outlook Using Outlook 1
richardwing Auto forward email that is moves into a specific outlook folder Outlook VBA and Custom Forms 5
L Recommendations for Utility to Backup Outlook 365 Account Settings Using Outlook 2
J Recommendations for Outlook Duplicate Email Remover Using Outlook 6
O Outlook - How to embed font ? (If at all possible) Using Outlook 2
Z New minimum Outlook for Windows version requirements for Microsoft 365/Exchange Online Using Outlook.com accounts in Outlook 26
T How to configure Outlook for two users on a single Windows account Using Outlook 3
R Outlook 2021 Having problem setting up outlook 2021 with windows 11. I have 3 gmail accounts and I want the 3 gmail, emails to merge into the same outlook input. Using Outlook.com accounts in Outlook 0
e_a_g_l_e_p_i Outlook 2021 all appointments not showing in calendar Using Outlook 2
S Outlook 365 Can I change the possible range of highlighting colours when writing an Outlook email? Using Outlook 1
B Outlook 213 keeps crashing. I just found out there are DMP files. How can I tell Why? Using Outlook 2
H Outlook 2016 related mails in outlook Outlook VBA and Custom Forms 13
S Outlook 2021 Can you make emails from 3 word domains "safe" by entering top 2 word domain into Safe List in Outlook? Using Outlook 1
@ Outlook Using Outlook 2

Similar threads

Top