Você também pode fazer isso a partir do VBA usando o Microsoft Outlook (ou pode substituir a função SendEmail no código por qualquer outra implementação de envio de mensagens desejada). Basta abrir a guia Developer, Visual Basic e colocar isso no módulo ThisWorkbook.
Option Explicit
Public Mail_Object As Object
Sub SU_458659()
Dim numofrows As Integer
Dim i As Integer
Dim ws As Worksheet
Dim startRow As Integer
Dim emailColumn As Integer
Dim passwordColumn As Integer
'TWEAKABLE: Change this to the first row to process
startRow = 2 'Assuming row 1 is header
'TWEAKABLE: Change ActiveSheet to a sheet name, etc. if you don't want it to run on the currently "active" (selected) sheet
Set ws = ActiveSheet
'TWEAKABLE: Change this to the row number ("A" is 1) of the email address
emailColumn = 1
'TWEAKABLE: Change this to the row number ("B" is 2) of the password field
passwordColumn = 2
'Get the number of rows in the sheet
numofrows = ws.Range("A1").Offset(ws.Rows.Count - 1, 0).End(xlUp).Row
'Shouldn't have to tweak anything in here
For i = startRow To numofrows
Dim emailCell As Range
Dim passwordCell As Range
Set emailCell = ws.Cells(i, emailColumn)
Set passwordCell = ws.Cells(i, passwordColumn)
If Not IsEmpty(emailCell) Then
Dim email As String
Dim password As String
email = CStr(emailCell.Value)
password = CStr(passwordCell.Value)
SendEmail email, password
End If
Next i
End Sub
Sub SendEmail(email As String, password As String)
Dim emailSubject As String
Dim emailSendFrom As String
Dim emailCc As String
Dim emailBcc As String
Dim prePassword As String
Dim postPassword As String
Dim Mail_Single As Variant
If Mail_Object Is Nothing Then Set Mail_Object = CreateObject("Outlook.Application")
'TWEAKABLE: Email subject
emailSubject = "CHANGE THIS"
'TWEAKABLE: The 'from' email address
emailSendFrom = "[email protected]"
'TWEAKABLE: The CC: field (just make it the empty string "" if you don't want a CC
emailCc = "[email protected]"
'TWEAKABLE: The BCC: field (just make it the empty string "" if you don't want a BCC)
emailBcc = "[email protected]"
'TWEAKABLE: The email body BEFORE the password
prePassword = "Your password is: """
'TWEAKABLE: The email body AFTER the password - vbCrLf is a newline like hitting Enter
postPassword = """." & vbCrLf & vbCrLf & "Have fun!"
On Error GoTo debugs
Set Mail_Single = Mail_Object.CreateItem(0)
With Mail_Single
.Subject = emailSubject
.To = email
.cc = emailCc
.BCC = emailBcc
.Body = prePassword & password & postPassword
'TWEAKABLE: Remove the following three lines before ".send" to remove message box confirmation
Dim retval As Variant
retval = MsgBox("Do you want to send an email to " & email & " with the password " & password & "?", vbYesNo, "Confirmation")
If retval = vbNo Then Exit Sub
.send
End With
debugs:
If Err.Description <> "" Then MsgBox Err.Description
End Sub