Tech
Forums
Jobs
Books
Events
Videos
Live
More
Interviews
Certification
Training
Career
Members
News
Blogs
Contribute
Article
Blog
Video
Ebook
Interview Question
.NET
.NET Assemblies
.NET Core
.NET Standard
Active Directory
ADO.NET
Agile Development
AJAX
Alexa Skills
Algorithms in C#
Android
Angular
Architecture
ArcObject
Artificial Intelligence
ASP.NET
ASP.NET Core
Augmented Reality
Aurelia
AWS
Azure
Backbonejs
Big Data
BizTalk Server
Blockchain
Bootstrap
Bot Framework
Business
C#
C# Corner
C, C++, MFC
Career Advice
Chapters
CIO
Cloud
COBOL.NET
Coding Best Practices
Cognitive Services
COM Interop
Compact Framework
Cortana Development
Cryptocurrency
Cryptography
Crystal Reports
Current Affairs
Custom Controls
Cyber Security
Data Mining
Databases & DBA
Design Patterns & Practices
DevOps
DirectX
Dynamics CRM
Enterprise Development
Entity Framework
Error Zone
Exception Handling
Expression Studio
F#
Files, Directory, IO
Games Programming
GDI+
General
Google Cloud
Google Development
Graphics Design
Hardware
Hiring and Recruitment
HoloLens
How do I
HTML 5
Internet & Web
Internet of Things
Ionic
iOS
Java
Java and .NET
JavaScript
JQuery
JSON
JSP
Knockout
kotlin
Leadership
Learn .NET
LightSwitch
LINQ
Machine Learning
Microsoft 365
Microsoft Office
Microsoft Phone
Mobile Development
Multithreading
NetBeans
Networking
Node.js
Office Development
OOP/OOD
Open Source
Operating Systems
Oracle
Outsourcing
Philosophy
PHP
Power BI
Printing in C#
Products
Progressive Web Apps
Project Management
Python
Q#
QlikView
R
React
Reports using C#
Robotics & Hardware
Ruby on Rails
Salesforce
Security
Servers
SharePoint
SignalR
Silverlight
Smart Devices
Software Testing
SQL Language
SQL Server
Startups
String in C#
Swift
TypeScript
Unity
UWP
Visual Basic .NET
Visual Studio
WCF
Wearables
Web Development
Web Services
Web3
Windows 10
Windows Controls
Windows Forms
Windows PowerShell
Windows Services
Workflow Foundation
WPF
Xamarin
XAML Standard
XML
XNA
XSharp
Register
Login
1
Answer
While executing my code I get exception
Raushan Raj
7y
368
1
Reply
I have implemented my work, but it is throwing exceptions- Exception from HRESULT: 0x800A03EC. It comes in the "for" loop. I have to extract the rows(A-H) where character "d" is present. Suppose if "d" is present in column "M" at "M6" cell, then I need to extract A6-H6 and send it via outlook mail.
Please help me!
This is what I have done so far :
using System;
using System.IO;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Excel = Microsoft.Office.Interop.Excel;
using Outlook = Microsoft.Office.Interop.Outlook;
using System.Collections;
namespace XYZ
{
class Program
{
//method to send email to outlook
public static void sendEMailThroughOUTLOOK()
{
try
{
// Create the Outlook application.
Outlook.Application oApp = new Outlook.Application();
// Create a new mail item.
Outlook.MailItem oMsg =
(Outlook.MailItem)oApp.CreateItem(Outlook.OlItemType.olMailItem);
// Set HTMLBody.
//add the body of the email
oMsg.HTMLBody = "See the details";
//Subject line oMsg.Subject = "Doc Info";
// Add a recipient.
Outlook.Recipients oRecips = (Outlook.Recipients)oMsg.Recipients;
// Change the recipient in the next line if necessary.
Outlook.Recipient oRecip = (Outlook.Recipient)oRecips.Add("
[email protected]
"), oRecip.Resolve();
// Send.
oMsg.Send();
// Clean up.
oRecip = null;
oRecips = null;
oMsg = null;
oApp = null;
}
catch (Exception ex)
{
}
}
private static string EX_PATH = @"F:\Document_Excel.xlsm";
private static Excel.Workbook AXBook = null;
private static Excel.Application AXApp = null;
private static Excel.Worksheet AXSheet = null;
public static string exception = "";
static void Main(string[] args)
{
if (args == null || args.Length < 4)
{
Console.WriteLine("Let's start the work!");
Console.WriteLine("press any key to continue");
Console.ReadLine();
}
else
{
AX_PATH = args[0];
}
AXApp = new Excel.Application();
AXApp.Visible = true;
exception = "";
try
{
AXBook = AXApp.Workbooks.Open(AX_PATH, 0, true, 5, "", "", true,Microsoft.Office.Interop.Excel.XlPlatform.xlWindows, "\t", false, false, 0, true, 1, 0);
}
catch (System.Exception ex)
{
exception = ex.Message;
}
exception = "";
try
{
AXSheet = (Excel.Worksheet)AXBook.Sheets["Sheet First"];
}
catch (Exception ex)
{
exception = ex.Message;
}
Console.WriteLine("Hello");
Excel.Range last = AXSheet.Cells.SpecialCells(Excel.XlCellType.xlCellTypeLastCell, Type.Missing);
Excel.Range range = AXSheet.get_Range("A1", last);
int lastUsedRow = last.Row;
int lastUsedColumn = last.Column;
Object missing = System.Type.Missing;
for (int i = AXSheet.Cells.get_Range("d", missing).Row + 1; i <= last.Row; i++)
{
Console.WriteLine("Hello");
sendEMailThroughOUTLOOK();
}
}
}
}
Post
Reset
Cancel
Answers (
1
)
Next Recommended Forum
Query get the largest ID number of the string ?
continous serial number for two grid views