so far i have in table format
$data :
Name Email
------- -------
person1 person1@gmail.com
person2 person2@gmail.com
I want to sent each person a seperate mail mentioning their name in respective email
i.e Hello how u doin’
Hello Person1 how u doin'
Hello Person2 how u doin'
I need help with integration with below code
#Email Part
function Send-Email() {
param (
[Parameter(mandatory=$true)][string]$To,
[Parameter(mandatory=$true)][string]$Subject,
[Parameter(mandatory=$true)][string]$Body
)
#Get user credentials
$username = (Get-Content -Path " ")[0]
$password = (Get-Content -Path " ")[0][1] | ConvertTo-SecureString -AsPlainText -Force
#Create Hash for Email
$email = @{
from = $username
to = $To
subject = $Subject
smtpserver = "smtp.gmail.com"
body = $Body
credential = New-Object System.Management.Automation.PSCredential -ArgumentList $username, $password
usessl = $true
verbose = $true
}
Send-MailMessage $email
}
Thanks for your help!