J
Jai sisodia
Guest
I'm using visual studio 2017, and i have written a program to open outlook with attached file. it is working fine on my local machine but, it is show error below error
Retrieving the COM class factory for component with CLSID {0006F03A-0000-0000-C000-000000000046} failed due to the following error: 80070005 Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED)).
my code is below
Application oApp = new Microsoft.Office.Interop.Outlook.Application();
// Create a new mail item.
MailItem oMsg = (MailItem)oApp.CreateItem(OlItemType.olMailItem);
// Set HTMLBody.
//add the body of the email
//oMsg.HTMLBody = "Hello, jay your message body will go here!!";
//Add an attachment.
String sDisplayName = "Attachment";//Display Text on Attachment
int iPosition = (int)oMsg.Body.Length + 1;
int iAttachType = (int)OlAttachmentType.olByValue;
//now attached the file
//Microsoft.Office.Interop.Outlook.Attachment oAttach = oMsg.Attachments.Add
// (fileName, iAttachType, iPosition, sDisplayName);
Microsoft.Office.Interop.Outlook.Attachment oAttach = oMsg.Attachments.Add(filename, iAttachType, iPosition, sDisplayName);
//Subject line
oMsg.Subject = "Resume";
// Add a recipient.
Recipients oRecips = (Recipients)oMsg.Recipients;
// Change the recipient in the next line if necessary.
Recipient oRecip = null;
if (!string.IsNullOrEmpty(ClientMail))
{
oRecip = (Recipient)oRecips.Add(ClientMail);
oRecip.Resolve();
}
// Send.
//System.Diagnostics.Process.Start("outlook.exe");
oMsg.Display();
//oMsg.Send();
// Clean up.
oRecip = null;
oRecips = null;
oMsg = null;
oApp = null;
please suggest me solution
Continue reading...
Retrieving the COM class factory for component with CLSID {0006F03A-0000-0000-C000-000000000046} failed due to the following error: 80070005 Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED)).
my code is below
Application oApp = new Microsoft.Office.Interop.Outlook.Application();
// Create a new mail item.
MailItem oMsg = (MailItem)oApp.CreateItem(OlItemType.olMailItem);
// Set HTMLBody.
//add the body of the email
//oMsg.HTMLBody = "Hello, jay your message body will go here!!";
//Add an attachment.
String sDisplayName = "Attachment";//Display Text on Attachment
int iPosition = (int)oMsg.Body.Length + 1;
int iAttachType = (int)OlAttachmentType.olByValue;
//now attached the file
//Microsoft.Office.Interop.Outlook.Attachment oAttach = oMsg.Attachments.Add
// (fileName, iAttachType, iPosition, sDisplayName);
Microsoft.Office.Interop.Outlook.Attachment oAttach = oMsg.Attachments.Add(filename, iAttachType, iPosition, sDisplayName);
//Subject line
oMsg.Subject = "Resume";
// Add a recipient.
Recipients oRecips = (Recipients)oMsg.Recipients;
// Change the recipient in the next line if necessary.
Recipient oRecip = null;
if (!string.IsNullOrEmpty(ClientMail))
{
oRecip = (Recipient)oRecips.Add(ClientMail);
oRecip.Resolve();
}
// Send.
//System.Diagnostics.Process.Start("outlook.exe");
oMsg.Display();
//oMsg.Send();
// Clean up.
oRecip = null;
oRecips = null;
oMsg = null;
oApp = null;
please suggest me solution
Continue reading...