ozm-jozsefvaros / KH-HR-AMK

0 stars 0 forks source link

Amikor elkészül a HTML doksi, készüljön egy email, ami értesíti a kollégákat #4

Closed ozm-jozsefvaros closed 7 months ago

ozm-jozsefvaros commented 10 months ago

'Ez tulajdonképpen csak egy mailto link, ami bcc -ben tartalmazza a kollégák nevét. A kollégák nevét az lkSzemélyek-ből kérdezheti le: Select [Hivatali email] From lkSzemélyek Where [Statusz neve] = "álláshely" AND [Főosztály] like "Humán*";

ozm-jozsefvaros commented 10 months ago
`Function ConcatenateEmails() As String
    Dim db As DAO.Database
    Dim rs As DAO.Recordset
    Dim emails As String

    Set db = CurrentDb
    Set rs = db.OpenRecordset("SELECT [Hivatali email] FROM lkSzemélyek WHERE [Statusz neve] = 'álláshely' AND [Főosztály] LIKE 'Humán*';")

    emails = ""

    If Not rs.EOF Then
        rs.MoveFirst
        Do Until rs.EOF
            If emails <> "" Then
                emails = emails & "; "
            End If
            emails = emails & rs![Hivatali email]
            rs.MoveNext
        Loop
    End If

    rs.Close
    Set rs = Nothing
    Set db = Nothing

    ConcatenateEmails = emails
End Function`
ozm-jozsefvaros commented 10 months ago

Ezzel az a gond, hogy a MsAccess csak 2074 (? vagy inkább 2047) karaktert tud átadni a mailto linken keresztül. Ezért egy html fájlba ( tag) kell kiírni a linket, majd onnan lehet kattintani.

ozm-jozsefvaros commented 9 months ago

A mailto linket egy másik HTML dokumentumba írja, ez JavaScript segítségével megnyitja, majd a dokumenumot bezárja.

ozm-jozsefvaros commented 9 months ago

window.onload = function() { var mailtoLink = document.getElementById('yourMailtoLink'); // Replace 'yourMailtoLink' with the actual ID of your mailto link if (mailtoLink) { mailtoLink.click(); } };

ozm-jozsefvaros commented 9 months ago

Private Sub btnGenerateHTML_Click() 'Specify the file path where you want to save the HTML file Dim filePath As String filePath = "C:\Path\To\Your\File\example.html"

'Create or overwrite the HTML file
Dim fileNumber As Integer
fileNumber = FreeFile
Open filePath For Output As fileNumber

'Write HTML content to the file
Print #fileNumber, "<html>"
Print #fileNumber, "<head>"
Print #fileNumber, "<script type='text/javascript'>"
Print #fileNumber, "function onLoad() {"
Print #fileNumber, "  document.getElementById('mailtoLink').click();"
Print #fileNumber, "  window.close();"
Print #fileNumber, "}"
Print #fileNumber, "</script>"
Print #fileNumber, "</head>"
Print #fileNumber, "<body onload='onLoad()'>"
Print #fileNumber, "<a id='mailtoLink' href='mailto:recipient@example.com'>Click to send email</a>"
Print #fileNumber, "</body>"
Print #fileNumber, "</html>"

'Close the file
Close fileNumber

MsgBox "HTML file generated successfully!", vbInformation

End Sub