Sending emails from query results, doesn't work under Windows 8 (1 Viewer)

Blancorn

Registered User.
Local time
Yesterday, 20:15
Joined
Feb 27, 2016
Messages
30
Hello everyone,

I am facing very strange problem in MS Access.
I have created database about materials in my little warehouse.
There is one form which allow me to send (by one click) an automatic email with the data from query results.
The code works under Windows 7. But when I run my database under Win8 or newest, it doesn't work.

Do you have any idea why?

Pleae find my code below:

Code:
Private Sub Polecenie26_Click()

'DoCmd.SetWarnings False
Me.Refresh

Dim mailQA As String
Dim Db As DAO.Database
Dim RS As DAO.Recordset
    Dim oApp As Object
    Dim oEmail As Object


Set Db = CurrentDb
Set RS = Db.OpenRecordset("kw_Sdp_eval_00_zgl")
With RS
    If .RecordCount > 0 Then
        .MoveFirst

    'Przejmij Outlook lub otwórz jeśli zamkniety
    On Error Resume Next
    Set oApp = GetObject(, "Outlook.Application")
    'sprawdź czy był otwarty
    If oApp Is Nothing Then
        Set oApp = CreateObject("Outlook.Application")
    End If
    On Error GoTo 0

    'stworz nową wiadomość e-mail
    Set oEmail = oApp.CreateItem(0)

    'wypełnij właściwości mail-a
    With oEmail

'wybiera grupe dystrybucyjna
If RS.Fields(21) = 196 Then
mailQA = "DLPMIPLHOLDYFGPOLSKA@pss.com"
Else
mailQA = "DLPMIPLHOLDYFGZAGRANICZNE@pss.com"
End If

        .To = mailQA
        .cc = RS.Fields(40)
        .bcc = ""
        .Subject = "[" & RS.Fields(2) & "." & RS.Fields(4) & "." & RS.Fields(0) & "] : Informacja o założeniu nowego holdu."

        'Format wiadomosci:
        '    3-rtf
        '    2-html
        '    1-tekst
        .BodyFormat = 2
'ZMIANA
         .HTMLBody = _
            "<html>" & _
                "Witam," & "<br><br>" & _
                "Informuję że został założony nowy hold / Please be informed about hold: " & "<br><br>" & _
                "Numer holdu / Hold number: " & "<b>" & RS.Fields(2) & "." & RS.Fields(4) & "." & RS.Fields(0) & "</b>" & "<br>" & _
                "Kod produktu / Product code: " & "<b>" & RS.Fields(7) & "</b>" & "<br>" & _
                "Nazwa produktu / Product name: " & "<b>" & RS.Fields(6) & "</b>" & "<br>" & _
                "Rynek / Market: " & "<b>" & RS.Fields(22) & "</b>" & "<br>" & _
                "Przyczyna / Reason: " & "<b>" & RS.Fields(8) & " - " & RS.Fields(9) & "</b>" & "<br>" & _
                "Data produkcji / Production date: " & "<b>" & RS.Fields(27) & " - " & RS.Fields(28) & "</b>" & "<br>" & _
                "Maszyna / Machine: " & "<b>" & RS.Fields(37) & "</b>" & "<br>" & _
                "Ilość / QTY: " & "<b>" & RS.Fields(10) & " " & RS.Fields(39) & "</b>" & "<br>" & _
                "Osoba która zauważyła wyrób niezgodny: " & "<b>" & RS.Fields(38) & "</b>" & "<br>" & _
                "Miejsce składowania / Storage location: " & "<b>" & RS.Fields(34) & " - " & RS.Fields(35) & "</b>" & "<br>" & "<br>" & _
                "Z poważaniem," & "<br>" & _
                RS.Fields(38) & "<br>" & _
                "</html>"
.ReadReceiptRequested = True
        .Recipients.ResolveAll
        'Pokaż formularz użytkownikowi
        .Display
    End With

    'Posprzątaj
    Set oEmail = Nothing
    Set oApp = Nothing
    End If
End With
RS.Close
Set RS = Nothing
Set Db = Nothing

End Sub
 

Ranman256

Well-known member
Local time
Yesterday, 23:15
Joined
Apr 9, 2015
Messages
4,339
Can't you just use
Docmd.sendobject ?
 

pbaldy

Wino Moderator
Staff member
Local time
Yesterday, 20:15
Joined
Aug 30, 2003
Messages
36,124
What error do you get? You may need to use a variable for the cc address, or wrap it in CStr().
 

Users who are viewing this thread

Top Bottom