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