Hello everyone. i have a big, big problem in my work regading sending
email to emails found on a table (in access). this requires me to use
VBA codes. This is currrently what i am using but there is an error
when i click on the send e-mail button (the problem as stated in access
lies in the mail.To function. Another funny thing is that i cannot send
to hotmail addresses except my company addresses. Can anyone expert in
this field help me??i am in deep trouble if i can't finish this by
friday. any help will be much appreciated. Thank You very much.
Private Sub cmdSend_Click()
Dim db As Database
Dim rs As Recordset
Dim mail As New CDONTS.NewMail
Dim strBodyContent As String
Dim Email As String
Set db = CurrentDb
Set rs = db.OpenRecordset("qryEmail")
rs.MoveFirst
Do Until rs.EOF
Email = Email & rs!Email & "; "
mail.To = Email
mail.BodyFormat = Text
mail.Subject = "United Parcel Service Job Opportunity"
mail.From = txtSenderEmail
mail.AttachFile (txtJobDescription)
strBodyContent = "Dear " & rs!Name & ", " & vbCrLf & vbCrLf &
"UPS is currently recruiting " & txtPosition & " in " & txtDepartment &
" Department. Enclosed is the job description for this position. We
would like to invite you to take up this opportunity by sending us your
updated resume to " & txtSenderEmail & ". The closing date for
submission will be on " & txtClosingDate & ". " & vbCrLf & vbCrLf &
"Please e-mail me if you have any queries on the above position. Thank
you. " & vbCrLf & vbCrLf & vbCrLf & "Regards, " & vbCrLf &
txtSenderName & vbCrLf & txtSenderDepartment & vbCrLf &
txtSenderCompany & vbCrLf & "Email: " & txtSenderEmail & ""
mail.body = strBodyContent
mail.Send
rs.MoveNext
Loop
MsgBox "Completed"
End Sub