SendGrid API for SMTP emails (1 Viewer)

BennyLinton

Registered User.
Local time
Today, 01:21
Joined
Feb 21, 2014
Messages
263
Does anyone have any familiarity using SendGrid API for SMTP emails? I'm trying to reference its key values in my VBA for automated sending of emails.
 

Uncle Gizmo

Nifty Access Guy
Staff member
Local time
Today, 08:21
Joined
Jul 9, 2003
Messages
16,243
I note that your post has yet to receive a reply. It may well have been missed by the members so I thought I would bump it up the list to give you a second go at getting an answer!
 

BennyLinton

Registered User.
Local time
Today, 01:21
Joined
Feb 21, 2014
Messages
263
There is a sample for using the SendGrid-API with VBA available right here on AWS.

We are no longer going to use Exchange Server for emailing from Access.
I have no idea how to alter my two blocks of code which is working:

Code:
Private Sub btnEmail_Click()

Dim rs As Recordset
Dim uq As String
Dim oApp As Object
Dim var As String

    Set oApp = GetObject(, "Outlook.Application")
    If Err <> 0 Then
         Set oApp = CreateObject("Outlook.Application")
        Started = True
    End If
On Error Resume Next

Set rs = CurrentDb.OpenRecordset("qryContactsEmailClient", dbReadOnly)
  If Not (rs.EOF And rs.BOF) Then
  rs.MoveFirst
     Do Until rs.EOF = True
        Set oItem = oApp.CreateItem(olMailItem)
        With oItem
            .Body = "This is a system-generated e-mail, please do not reply unless changes are needed to your Name." & vbNewLine & _
                          " " & vbNewLine & _
                          " " & vbNewLine & _
                    "Dear " & rs!FirstName & "," & vbNewLine & _
                          " " & vbNewLine & _
                          " " & vbNewLine & _
                    "Please carefully review your complete name below as it will appear on your printed certificate:" & vbNewLine & _
                          " " & vbNewLine & _
                          " " & vbNewLine & _
                    "" & rs!FirstName & " " & (rs!MiddleName + " ") & rs!LastName & " " & vbNewLine & _
                          " " & vbNewLine & _
                    "Thank you, GCDF Staff"
        .From = "GCDF"
        .To = rs!fldEmailAddress
        .Subject = "Test - Matt please reply"
        .send
With CurrentDb.CreateQueryDef("", "UPDATE Applicants set Applicants.EmailedToClient = -1, Applicants.DateEmailedClient = Now() WHERE Applicants.[GCDF No] = @1")
.Parameters(0) = rs(0)
.Execute
End With
        End With
        rs.MoveNext
        Loop
  Else
    MsgBox "There are no records in the recordset."
  End If
    rs.Close
    Set rs = Nothing
     Set oItem = Nothing
       If Started Then
           oApp.Quit
    End If
    DoCmd.Close acForm, "f_Admin_Main"
        MsgBox "Emails have now been sent to listed individuals."
End Sub

Code:
Private Sub btnEmail_Click()

Dim updateSent As String

DoCmd.SendObject acSendQuery, "qryContactsPrinter", acFormatXLS, "campbell@nbcc.org", , , "GCDF Email Example to Printing Company", "Please review your data below for accuracy"

DoCmd.SetWarnings False
updateSent = "UPDATE Applicants set Applicants.EmailedToPrinter = -1, Applicants.DateEmailedPrinter = Now() WHERE Applicants.EmailedToPrinter = 0"
DoCmd.RunSQL updateSent
DoCmd.SetWarnings True

MsgBox "Excel Spreadsheet has been emailed to the printing company."
DoCmd.Close acForm, "f_Admin_Main_Printer"
End Sub
 

Users who are viewing this thread

Top Bottom