Excel issue

Duckduck

Well-known member
  • Mar 4, 2023
    1,691
    927
    113
    Excel sheet ekaka due date ekak remid karanna puluwanda email ekak through. Automatic email ekak wage. Kohomada karanne? Office eke wadak bn. Therenna kohomada karanne kiyala

    Individual row eke data due date reminder row wise yawanna puluwanda?
    ------ Post added on May 30, 2024 at 7:38 PM
     
    • Like
    Reactions: kinkon and NRTG

    hasithayad

    Well-known member
  • Sep 28, 2011
    30,793
    1
    44,991
    113
    excel file එක නිතරම open වෙලා තියන එකක් නෙවෙයි නිසා වෙනම සොෆ්ට්වෙයා එකක් හදලා run කරල තියන්න ඕනෙ office automation/api එකකින් සැරින් සැරේ අදාල cell values read කරලා email එක යන විදියට. windows service එකක් විදියට හැදුවනම් හරි
     
    • Like
    Reactions: NRTG and Duckduck

    poopoo

    Well-known member
  • Nov 18, 2021
    5,766
    11,419
    113
    Excel sheet ekaka due date ekak remid karanna puluwanda email ekak through
    මේකද වෙන්න ඕන?

    excel sheet එකක dates වගයක් තියෙනවා, ඒක due වුණ ගමන් outlook mail එකක් යවන්නද ඕන?
    office එකේ වැඩක් නම් මුලින්ම බලන්න power platform license එකක් assign වෙලා තියෙනවද කියලා, 3rd party scripts use කරන්න එපා අහන්නේ නැතුව

    try එකක් දෙන්නම්, හරි ගියොත් පාන්දර එකට කලින් update කරන්නම්
    නැත්නම් කෙල වුණා 🥴
     
    Last edited:
    • Like
    Reactions: NRTG and Duckduck

    imhotep

    Well-known member
  • Mar 29, 2017
    14,824
    8
    35,334
    113
    • Like
    Reactions: NRTG and Duckduck

    Duckduck

    Well-known member
  • Mar 4, 2023
    1,691
    927
    113
    excel file එක නිතරම open වෙලා තියන එකක් නෙවෙයි නිසා වෙනම සොෆ්ට්වෙයා එකක් හදලා run කරල තියන්න ඕනෙ office automation/api එකකින් සැරින් සැරේ අදාල cell values read කරලා email එක යන විදියට. windows service එකක් විදියට හැදුවනම් හරි
    Loku knowledge ekak na bn. Mama witharak newei edit karanne, hamotama data add karanna puluwan wenna ona. 3rd party exe installation ba, ekai google sheet baluwe. Puluwan suport ekak deepan🤝

    Use power automate scheduled flow. Easy task. Hbi one drive or SharePoint wage cloud thiyenna one. Local file ekak nan PA Desktop flow use krnna wei.
    Cloud thibunama kamak na. Ethakota hamotama edit karanna puluwanne. Kohomada karanne. Mama ofcekata gihin file eka attach karannam, row ekak karala pennanawanam athi, Itapasse thaniyen match ekak gahannam
    ------ Post added on May 31, 2024 at 7:29 AM

    මේකද වෙන්න ඕන?

    excel sheet එකක dates වගයක් තියෙනවා, ඒක due වුණ ගමන් outlook mail එකක් යවන්නද ඕන?
    office එකේ වැඩක් නම් මුලින්ම බලන්න power platform license එකක් assign වෙලා තියෙනවද කියලා, 3rd party scripts use කරන්න එපා අහන්නේ නැතුව

    try එකක් දෙන්නම්, හරි ගියොත් පාන්දර එකට කලින් update කරන්නම්
    නැත්නම් කෙල වුණා 🥴
    Ow 3rd party ba. Endpoint security thiyenawa. Mama UK clothing brand ekaka fabric technologist kenek. Physical karanna wada ambaneta thiyenawa, me due date wade very important, anik wadath ekka mekata time ekak denna amarui. Ekai automated karanna baluwe
    ------ Post added on May 31, 2024 at 7:36 AM

    Balala kiyannam
    ------ Post added on May 31, 2024 at 7:37 AM
     
    • Like
    Reactions: NRTG

    Gwynbleidd

    Well-known member
  • Aug 7, 2020
    11,794
    22,053
    113
    Kaer Morhen
    thewitcher.com
    Cloud thibunama kamak na. Ethakota hamotama edit karanna puluwanne. Kohomada karanne. Mama ofcekata gihin file eka attach karannam, row ekak karala pennanawanam athi, Itapasse thaniyen match ekak gahannam
    ------ Post added on May 31, 2024 at 7:29 AM
    admint kiyala license eka assign wela nattan eka on krgnna, khmth 30 day trail ekak tynw + m365 account ekt free version use krnna puluwn power automate, business account ekta. file eka onedrive ekta wage daganna oyage. eta passe meka follow krla krgnna 30 mins yai poddak purudu nti hinda. thawa automate krnna puluwn ewa list krgena oken karaganna. wada lesi. mmth me wage ekkin thama mulinm patan gatte

     
    • Like
    Reactions: Duckduck and NRTG

    Duckduck

    Well-known member
  • Mar 4, 2023
    1,691
    927
    113
    admint kiyala license eka assign wela nattan eka on krgnna, khmth 30 day trail ekak tynw + m365 account ekt free version use krnna puluwn power automate, business account ekta. file eka onedrive ekta wage daganna oyage. eta passe meka follow krla krgnna 30 mins yai poddak purudu nti hinda. thawa automate krnna puluwn ewa list krgena oken karaganna. wada lesi. mmth me wage ekkin thama mulinm patan gatte


    try karala balannam. thanks bn
     
    • Like
    Reactions: NRTG and Gwynbleidd

    soori19

    Active member
  • Dec 28, 2016
    103
    84
    28
    Mama godak issara liwwe me program eka. Main module eka oyage sheet ekata galapena widiyata wenas karala ganna.


    #Const LateBind = True

    Const olMinimized As Long = 1
    Const olMaximized As Long = 2
    Const olFolderInbox As Long = 6

    #If LateBind Then

    Public Function OutlookApp( _
    Optional WindowState As Long = olMinimized, _
    Optional ReleaseIt As Boolean = False _
    ) As Object
    Static o As Object
    #Else
    Public Function OutlookApp( _
    Optional WindowState As Outlook.OlWindowState = olMinimized, _
    Optional ReleaseIt As Boolean _
    ) As Outlook.Application
    Static o As Outlook.Application
    #End If
    On Error GoTo ErrHandler

    Select Case True
    Case o Is Nothing, Len(o.Name) = 0
    Set o = GetObject(, "Outlook.Application")
    If o.Explorers.Count = 0 Then
    InitOutlook:
    'Open inbox to prevent errors with security prompts
    o.Session.GetDefaultFolder(olFolderInbox).Display
    o.ActiveExplorer.WindowState = WindowState
    End If
    Case ReleaseIt
    Set o = Nothing
    End Select
    Set OutlookApp = o

    ExitProc:
    Exit Function
    ErrHandler:
    Select Case Err.Number
    Case -2147352567
    'User cancelled setup, silently exit
    Set o = Nothing
    Case 429, 462
    Set o = GetOutlookApp()
    If o Is Nothing Then
    Err.Raise 429, "OutlookApp", "Outlook Application does not appear to be installed."
    Else
    Resume InitOutlook
    End If
    Case Else
    MsgBox "Error " & Err.Number & ": " & Err.Description, vbCritical, "Unexpected error"
    End Select
    Resume ExitProc
    Resume
    End Function

    #If LateBind Then
    Private Function GetOutlookApp() As Object
    #Else
    Private Function GetOutlookApp() As Outlook.Application
    #End If
    On Error GoTo ErrHandler

    Set GetOutlookApp = CreateObject("Outlook.Application")

    ExitProc:
    Exit Function
    ErrHandler:
    Select Case Err.Number
    Case Else
    'Do not raise any errors
    Set GetOutlookApp = Nothing
    End Select
    Resume ExitProc
    Resume
    End Function




    Sub Main()

    Dim WS_Main As Worksheet
    Dim WS_New As Worksheet
    Dim WS_Template As Worksheet

    Dim i As Long
    Dim WS_Main_ColA_LastRow As Long

    Dim EAddress As String
    Dim AttachmentPath As String

    Set WS_Main = ActiveSheet
    Set WS_Template = Worksheets("TemplateSheet")

    'Find last row of column A
    With WS_Main
    WS_Main_ColA_LastRow = .Cells(.Rows.Count, "A").End(xlUp).Row
    End With

    WS_Template.Visible = True

    'On Error GoTo ErrorHandler:
    For i = 4 To WS_Main_ColA_LastRow

    If StrComp(Trim(WS_Main.Range("AD" & i).Value), "Do not send email", vbTextCompare) <> 0 Then

    'Create a copy of the template sheet
    WS_Template.Copy After:=Sheets(Sheets.Count)
    'Sheets("Oct 24, 2015").Select
    Set WS_New = ActiveSheet

    'START DATE and END DATE
    WS_Main.Activate
    Range("B1:C1").Select
    Selection.Copy
    WS_New.Select
    WS_New.Range("D9").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
    :=False, Transpose:=False

    'Pay date
    WS_Main.Activate
    Range("F1").Select
    Selection.Copy
    WS_New.Select
    WS_New.Range("F9").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
    :=False, Transpose:=False

    'Name
    WS_Main.Activate
    Range("T" & i).Select
    Selection.Copy
    WS_New.Select
    WS_New.Range("B11").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
    :=False, Transpose:=False

    'Percent and Payment:JMD
    WS_Main.Activate
    Range("U" & i & ":V" & i).Select
    Selection.Copy
    WS_New.Select
    WS_New.Range("E11").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
    :=False, Transpose:=False

    'remaing values
    WS_Main.Activate
    Range("W" & i & ":AA" & i).Select
    Selection.Copy
    WS_New.Select
    WS_New.Range("F15").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
    :=False, Transpose:=True

    WS_Main.Activate
    Range("AC" & i).Select
    Selection.Copy
    WS_New.Select
    WS_New.Range("C18").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
    :=False, Transpose:=False

    WS_New.Range("A1").Select
    WS_New.Name = "Paystub_" & WS_New.Range("B11").Value

    Call SavePdf(WS_New)
    DoEvents
    '***
    EAddress = WS_Main.Range("AB" & i).Value
    AttachmentPath = ThisWorkbook.Path & "\" & _
    Trim(WS_Main.Range("T" & i).Value) & "_" & Month(CDate(WS_Main.Range("F1").Value)) & "_" _
    & Day(CDate(WS_Main.Range("F1").Value)) & "_" & Year(CDate(WS_Main.Range("F1").Value)) & ".pdf"

    Call SendEmail(EAddress, AttachmentPath)
    DoEvents
    '***

    Application.DisplayAlerts = False
    WS_New.Delete
    Application.DisplayAlerts = True

    End If
    Next i


    'ErrorHandler:
    Worksheets("TemplateSheet").Visible = xlVeryHidden

    If Err = 0 Then
    MsgBox "Completed", vbInformation, ""
    Else
    MsgBox "Error occured!", vbCritical, "warning!"
    End If


    End Sub




    Sub SavePdf(WS As Worksheet)

    'Dim WS As Worksheet
    'Set WS = Worksheets("Paystub")

    WS.PageSetup.Orientation = xlLandscape

    FilePath = ThisWorkbook.Path

    WS.Select

    Dim fileName As String
    fileName = Trim(WS.Range("B11").Value) & "_" & Month(CDate(WS.Range("F9").Value)) & "_" & _
    Day(CDate(WS.Range("F9").Value)) & "_" & Year(CDate(WS.Range("F9").Value))

    'MsgBox Month(CDate(Range("F9").Value))
    'MsgBox Day(CDate(Range("F9").Value))
    'MsgBox Year(CDate(Range("F9").Value))

    ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, fileName:=ThisWorkbook.Path & "\" & fileName & ".pdf", _
    Quality:=xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas:=False

    'MsgBox "Completed", vbInformation, ""


    End Sub
    Sub MyMacroThatUseOutlook()
    Dim OutApp As Object
    Set OutApp = OutlookApp()
    'Automate OutApp as desired
    End Sub

    Sub SendEmail(EmailAddress As String, FilePathtoAdd As String)


    Dim messageBody As String

    messageBody = "Hi," & vbCrLf & vbCrLf & _
    "Here 's your pay information for the week. Please review." & vbCrLf & vbCrLf & _
    "Please store this information in a safe place." & vbCrLf & vbCrLf & _
    "Regards, " & vbCrLf & _
    "Mgmt"

    Dim OutApp As Object
    Dim objMsg As MailItem

    Set OutApp = OutlookApp()
    Set objMsg = OutApp.CreateItem(olMailItem)

    With objMsg
    .To = EmailAddress
    .Subject = "Pay Information"
    '.Categories = "Test"
    .Body = messageBody
    .Attachments.Add FilePathtoAdd
    '.Display 'use .display to send it automatically
    .Send 'to send it automatically

    End With

    Set objMsg = Nothing
    Set OutApp = Nothing



    End Sub
     

    Scarface

    Well-known member
  • Dec 8, 2008
    1,711
    471
    83
    morphine base
    To send reminder emails based on dates in an Excel file, you can use Python with libraries like pandas to read the Excel file and smtplib to send emails. Here's a step-by-step guide to accomplish this:

    1. Install required libraries:

    Copy
    pip install pandas openpyxl

    1. Create a Python script:
    python
    Copy
    import pandas as pd
    import smtplib
    from email.mime.text import MIMEText
    from email.mime.multipart import MIMEMultipart
    from datetime import datetime, timedelta

    # Function to send email
    def send_email(to_email, subject, body):
    # Email configuration
    from_email = "[email protected]"
    password = "your_email_password"
    smtp_server = "smtp.example.com"
    smtp_port = 587

    # Create message
    msg = MIMEMultipart()
    msg['From'] = from_email
    msg['To'] = to_email
    msg['Subject'] = subject
    msg.attach(MIMEText(body, 'plain'))

    # Send email
    with smtplib.SMTP(smtp_server, smtp_port) as server:
    server.starttls()
    server.login(from_email, password)
    server.send_message(msg)

    # Read Excel file
    df = pd.read_excel('your_excel_file.xlsx')

    # Get today's date
    today = datetime.now().date()

    # Iterate through rows
    for index, row in df.iterrows():
    reminder_date = row['ReminderDate'].date()
    email = row['Email']
    message = row['Message']

    # Check if reminder date is today
    if reminder_date == today:
    subject = "Reminder"
    body = f"Hello,\n\nThis is a reminder: {message}\n\nBest regards,\nYour Reminder System"
    send_email(email, subject, body)
    print(f"Reminder sent to {email}")

    print("Reminder process completed.")

    1. Customize the script:
      • Replace 'your_excel_file.xlsx' with the path to your Excel file.
      • Update the email configuration in the send_email function with your email details.
      • Adjust the column names ('ReminderDate', 'Email', 'Message') to match your Excel file structure.
    2. Prepare your Excel file: Ensure your Excel file has at least these columns:
      • ReminderDate: The date for sending the reminder
      • Email: The recipient's email address
      • Message: The reminder message
    3. Run the script: Execute the Python script. It will:
      • Read the Excel file
      • Check for reminders due today
      • Send emails for matching reminders
    4. Automate the script: To run this automatically every day:
      • On Windows: Use Task Scheduler
      • On macOS or Linux: Use cron jobs
    Remember to handle your email credentials securely. Consider using environment variables or a secure configuration file instead of hardcoding them in the script.

    Also, be aware of your email provider's sending limits to avoid being flagged as spam.

    Would you like me to explain any part of this process in more detail?
     

    asknrk

    Well-known member
  • Feb 10, 2007
    2,843
    791
    113
    @Thusithaya
    Mama godak issara liwwe me program eka. Main module eka oyage sheet ekata galapena widiyata wenas karala ganna.


    #Const LateBind = True

    Const olMinimized As Long = 1
    Const olMaximized As Long = 2
    Const olFolderInbox As Long = 6

    #If LateBind Then

    Public Function OutlookApp( _
    Optional WindowState As Long = olMinimized, _
    Optional ReleaseIt As Boolean = False _
    ) As Object
    Static o As Object
    #Else
    Public Function OutlookApp( _
    Optional WindowState As Outlook.OlWindowState = olMinimized, _
    Optional ReleaseIt As Boolean _
    ) As Outlook.Application
    Static o As Outlook.Application
    #End If
    On Error GoTo ErrHandler

    Select Case True
    Case o Is Nothing, Len(o.Name) = 0
    Set o = GetObject(, "Outlook.Application")
    If o.Explorers.Count = 0 Then
    InitOutlook:
    'Open inbox to prevent errors with security prompts
    o.Session.GetDefaultFolder(olFolderInbox).Display
    o.ActiveExplorer.WindowState = WindowState
    End If
    Case ReleaseIt
    Set o = Nothing
    End Select
    Set OutlookApp = o

    ExitProc:
    Exit Function
    ErrHandler:
    Select Case Err.Number
    Case -2147352567
    'User cancelled setup, silently exit
    Set o = Nothing
    Case 429, 462
    Set o = GetOutlookApp()
    If o Is Nothing Then
    Err.Raise 429, "OutlookApp", "Outlook Application does not appear to be installed."
    Else
    Resume InitOutlook
    End If
    Case Else
    MsgBox "Error " & Err.Number & ": " & Err.Description, vbCritical, "Unexpected error"
    End Select
    Resume ExitProc
    Resume
    End Function

    #If LateBind Then
    Private Function GetOutlookApp() As Object
    #Else
    Private Function GetOutlookApp() As Outlook.Application
    #End If
    On Error GoTo ErrHandler

    Set GetOutlookApp = CreateObject("Outlook.Application")

    ExitProc:
    Exit Function
    ErrHandler:
    Select Case Err.Number
    Case Else
    'Do not raise any errors
    Set GetOutlookApp = Nothing
    End Select
    Resume ExitProc
    Resume
    End Function




    Sub Main()

    Dim WS_Main As Worksheet
    Dim WS_New As Worksheet
    Dim WS_Template As Worksheet

    Dim i As Long
    Dim WS_Main_ColA_LastRow As Long

    Dim EAddress As String
    Dim AttachmentPath As String

    Set WS_Main = ActiveSheet
    Set WS_Template = Worksheets("TemplateSheet")

    'Find last row of column A
    With WS_Main
    WS_Main_ColA_LastRow = .Cells(.Rows.Count, "A").End(xlUp).Row
    End With

    WS_Template.Visible = True

    'On Error GoTo ErrorHandler:
    For i = 4 To WS_Main_ColA_LastRow

    If StrComp(Trim(WS_Main.Range("AD" & i).Value), "Do not send email", vbTextCompare) <> 0 Then

    'Create a copy of the template sheet
    WS_Template.Copy After:=Sheets(Sheets.Count)
    'Sheets("Oct 24, 2015").Select
    Set WS_New = ActiveSheet

    'START DATE and END DATE
    WS_Main.Activate
    Range("B1:C1").Select
    Selection.Copy
    WS_New.Select
    WS_New.Range("D9").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
    :=False, Transpose:=False

    'Pay date
    WS_Main.Activate
    Range("F1").Select
    Selection.Copy
    WS_New.Select
    WS_New.Range("F9").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
    :=False, Transpose:=False

    'Name
    WS_Main.Activate
    Range("T" & i).Select
    Selection.Copy
    WS_New.Select
    WS_New.Range("B11").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
    :=False, Transpose:=False

    'Percent and Payment:JMD
    WS_Main.Activate
    Range("U" & i & ":V" & i).Select
    Selection.Copy
    WS_New.Select
    WS_New.Range("E11").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
    :=False, Transpose:=False

    'remaing values
    WS_Main.Activate
    Range("W" & i & ":AA" & i).Select
    Selection.Copy
    WS_New.Select
    WS_New.Range("F15").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
    :=False, Transpose:=True

    WS_Main.Activate
    Range("AC" & i).Select
    Selection.Copy
    WS_New.Select
    WS_New.Range("C18").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
    :=False, Transpose:=False

    WS_New.Range("A1").Select
    WS_New.Name = "Paystub_" & WS_New.Range("B11").Value

    Call SavePdf(WS_New)
    DoEvents
    '***
    EAddress = WS_Main.Range("AB" & i).Value
    AttachmentPath = ThisWorkbook.Path & "\" & _
    Trim(WS_Main.Range("T" & i).Value) & "_" & Month(CDate(WS_Main.Range("F1").Value)) & "_" _
    & Day(CDate(WS_Main.Range("F1").Value)) & "_" & Year(CDate(WS_Main.Range("F1").Value)) & ".pdf"

    Call SendEmail(EAddress, AttachmentPath)
    DoEvents
    '***

    Application.DisplayAlerts = False
    WS_New.Delete
    Application.DisplayAlerts = True

    End If
    Next i


    'ErrorHandler:
    Worksheets("TemplateSheet").Visible = xlVeryHidden

    If Err = 0 Then
    MsgBox "Completed", vbInformation, ""
    Else
    MsgBox "Error occured!", vbCritical, "warning!"
    End If


    End Sub




    Sub SavePdf(WS As Worksheet)

    'Dim WS As Worksheet
    'Set WS = Worksheets("Paystub")

    WS.PageSetup.Orientation = xlLandscape

    FilePath = ThisWorkbook.Path

    WS.Select

    Dim fileName As String
    fileName = Trim(WS.Range("B11").Value) & "_" & Month(CDate(WS.Range("F9").Value)) & "_" & _
    Day(CDate(WS.Range("F9").Value)) & "_" & Year(CDate(WS.Range("F9").Value))

    'MsgBox Month(CDate(Range("F9").Value))
    'MsgBox Day(CDate(Range("F9").Value))
    'MsgBox Year(CDate(Range("F9").Value))

    ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, fileName:=ThisWorkbook.Path & "\" & fileName & ".pdf", _
    Quality:=xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas:=False

    'MsgBox "Completed", vbInformation, ""


    End Sub
    Sub MyMacroThatUseOutlook()
    Dim OutApp As Object
    Set OutApp = OutlookApp()
    'Automate OutApp as desired
    End Sub

    Sub SendEmail(EmailAddress As String, FilePathtoAdd As String)


    Dim messageBody As String

    messageBody = "Hi," & vbCrLf & vbCrLf & _
    "Here 's your pay information for the week. Please review." & vbCrLf & vbCrLf & _
    "Please store this information in a safe place." & vbCrLf & vbCrLf & _
    "Regards, " & vbCrLf & _
    "Mgmt"

    Dim OutApp As Object
    Dim objMsg As MailItem

    Set OutApp = OutlookApp()
    Set objMsg = OutApp.CreateItem(olMailItem)

    With objMsg
    .To = EmailAddress
    .Subject = "Pay Information"
    '.Categories = "Test"
    .Body = messageBody
    .Attachments.Add FilePathtoAdd
    '.Display 'use .display to send it automatically
    .Send 'to send it automatically

    End With

    Set objMsg = Nothing
    Set OutApp = Nothing



    End Sub
    Did you try this one?