Outlook programming

  • Thread starter Thread starter Oras
  • Start date Start date
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
 
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

>
 
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.
 
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
G Outlook translation feature is off Using Outlook 2
J Outlook 2010 does not let me put any account Using Outlook.com accounts in Outlook 3
P 3 of 5 PST files don't install from d:\outlook but only from D:\ Using Outlook 7
HarvMan January Windows 10 preview update force installs new Outlook Using Outlook 1
L Outlook 2010 - new installation on Windows 11 - aplzod32.dll is not a valid Add-in Using Outlook 9
J Outlook troubleshooting/logging - option grayed out Using Outlook 2
B Arrows missing from Outlook emails vertical scrollbar Using Outlook 0
G Outlook 2021 (New) doesn't respect default browser Using Outlook 8
B Outlook or iPhone turning tabs into spaces in Outlook Notes Using Outlook 1
P newly installed Office 365 includes OLD Outlook Using Outlook 6
R Outlook ribbon menu default? Using Outlook 7
H Spam email in Gmail not visible in Outlook Using Outlook 3
J How to transfer Win 10 Outlook to new Windows 11 pc? Using Outlook 11
J Renegade spam URL line displayed in old local Outlook 365 email title Using Outlook 3
G Reduce whitespace in Outlook desktop Contact Cards display Using Outlook 3
C Outlook classic via 365 Using Outlook 2
Dr. Demento Analogous Outlook code to read info into an array (or collection or whatever) Outlook VBA and Custom Forms 7
S Repair Outlook Using Outlook 8
V Outlook Form ListBox is not editable Outlook VBA and Custom Forms 2
F Outlook's contacts Using Outlook 1
D Outlook 2003 stopped dead Using Outlook 2
G Cannot receive emails from gmail account in Outlook 365 Using Outlook 1
E "Cannot display the folder. MS Outlook cannot access the specified file location" Using Outlook 8
P Outlook 2016 Working Offline Using Outlook 2
Rupert Dragwater Cannot reestablish gmail (email address) account in Outlook 365 Using Outlook 11
O Outlook 365 synchronisieren Exchange Server Administration 1
kburrows Outlook Classic - JPG files are corrupted when opened or saved Using Outlook 3
F Sync Outlook Calendar Using Outlook 0
G Change default font size in sticky notes - Outlook Desktop 2021 Using Outlook 2
C VBA in "New Outlook?" Using Outlook 0
D New Outlook with Business Basic Plans Using Outlook 0
D Outlook 2021 not working with Outlook 2003 installed Using Outlook 5
D Outlook 2003 stopped working - get they dialog box asking for username & Password Using Outlook 2
T Outlook 2021 hangs in close on taskbar occasionally Using Outlook 1
M Duplicate removal feature in Outlook 2021 is faulty Using Outlook 2
D.Moore Outlook COM addins source folder Using Outlook 12
P Removing Outlook 365 Account from Send/Receive Using Outlook 3
kburrows Outlook Automatically Merging Contacts Using Outlook 2
A Outlook 2016 Outlook 2016 vs. New Outlook Using Outlook 4
D Outlook Desktop App Email Software Using Outlook 0
efire9207 VBA Outlook Contacts Outlook VBA and Custom Forms 6
M Outlook not logging in to server Using Outlook 0
J Outlook macro to run before email is being send Outlook VBA and Custom Forms 3
R Outlook 2021 change view Using Outlook 2
K Outlook font corrupted in some point sizes, resets on close/open Using Outlook 2
J Is the Windows Outlook Tasks module really going to be gone? Using Outlook 6
F Outlook 2010 and Hotmail Using Outlook 1
A Outlook 2021 needs 'enter' for people search Using Outlook 2

Similar threads

Back
Top