CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Apr 2017
    Posts
    7

    Extract specific data from excel file and mail via outlook 2007

    I am new to C#. Please help me with my problem!

    I have an Excel file in which multiple sheets are present. From "Sheet1", I have to look for a character "d" in column "M". If "d" is present in some cells of column "M", then I have to mail the row contents (cells A-H) where the character is found to a mail address with the contents extracted through Microsoft Outlook 2007.

  2. #2
    2kaud's Avatar
    2kaud is online now Super Moderator Power Poster
    Join Date
    Dec 2012
    Location
    England
    Posts
    7,824

    Re: Extract specific data from excel file and mail via outlook 2007

    [Thread moved to c# forum]
    All advice is offered in good faith only. All my code is tested (unless stated explicitly otherwise) with the latest version of Microsoft Visual Studio (using the supported features of the latest standard) and is offered as examples only - not as production quality. I cannot offer advice regarding any other c/c++ compiler/IDE or incompatibilities with VS. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/ and can be used without reference or acknowledgement. Also note that I only provide advice and guidance via the forums - and not via private messages!

    C++23 Compiler: Microsoft VS2022 (17.6.5)

  3. #3
    Join Date
    Apr 2017
    Posts
    7

    Re: Extract specific data from excel file and mail via outlook 2007

    I have implemented my work using VBA (macros). I want to convert my VBA code to C#. I want help in converting my code to C#.

    My implementation so far is as under:

    Code:
    Option Explicit
    Sub CopyRow()
    Dim i As Integer
    Dim lRow As Long, nextRow As Long
    lRow = Sheets("Document List").Cells(Rows.Count, "M").End(xlUp).Row
    For i = 1 To lRow
    If InStr(1, LCase(Range("M" & i)), "d") <> 0 Then
    nextRow = Sheets("Sheet1").Range("A" & Rows.Count).End(xlUp).Row + 1
    Range("A" & i & ":H" & i).Copy Destination:=Sheets("Sheet1").Range("A" & nextRow)
    End If
    Next i
    End Sub
    Last edited by 2kaud; April 14th, 2017 at 02:47 AM. Reason: Added code tags

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured