Bulk Emailer using different body texts

Number11

Member
Local time
Today, 03:34
Joined
Jan 29, 2020
Messages
617
So i need to create some bulk emailing, using the subject and body stored within a ms access table

Table would look like

Subject
Body

I want to use VBS to send email using the data within the table,

is such a thing possible
 
chatgpt has this answer using VBS

Code:
' Set up constants and objects
Dim conn, rs, outlookApp, mailItem

' Create a connection to the Access database
Set conn = CreateObject("ADODB.Connection")
conn.Open "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Path\To\YourDatabase.accdb;"

' Open a recordset for the table (replace 'YourTableName' with your actual table name)
Set rs = conn.Execute("SELECT EmailAddress, Subject, Body FROM YourTableName")

' Create Outlook application object
Set outlookApp = CreateObject("Outlook.Application")

' Loop through the recordset and send emails
Do Until rs.EOF
    If Not IsNull(rs("EmailAddress")) Then
        ' Create a new email item
        Set mailItem = outlookApp.CreateItem(0)
        mailItem.To = rs("EmailAddress")
        mailItem.Subject = rs("Subject")
        mailItem.Body = rs("Body")
        
        ' Send the email (use Display instead of Send for previewing)
        mailItem.Send
    End If
    
    ' Move to the next record
    rs.MoveNext
Loop

' Clean up
rs.Close
conn.Close
Set mailItem = Nothing
Set outlookApp = Nothing
Set rs = Nothing
Set conn = Nothing

MsgBox "Emails sent successfully!"
 
Why VBS?
 

Users who are viewing this thread

Back
Top Bottom