Email to text (1 Viewer)

Mark_F

New member
Local time
Today, 10:54
Joined
Nov 5, 2021
Messages
10
Hi everyone.
I am trying to send email to text via outlook. I have a list of numbers which need the carrier suffix as in the code. The problem is that the suffix is only added to the last number instead of all numbers. What have I done wrong? I don't know too much about coding.
PLEASE HELP

Dim OObj As Outlook.Application
Dim OMsg As Outlook.MailItem
Dim db As Database
Dim rs As Recordset
Dim PersonalContactNumber As String
Set OObj = CreateObject("Outlook.Application")
Set OMsg = OObj.CreateItem(olMailItem)
Set db = CurrentDb
Set rs = db.OpenRecordset("studentlistq")

With rs

If .EOF And .BOF Then
MsgBox "No emails will be sent because there are no records assigned from the list", vbInformation
Else
PersonalContactNumber = ""
Do Until .EOF
PersonalContactNumber = PersonalContactNumber & ";" & ![PersonalContactNumber]
.MoveNext
Loop

OMsg.To = PersonalContactNumber & "@voda.co.za"

OMsg.Display

End If

End With
rs.Close
db.Close
Set rs = Nothing
Set db = Nothing
Set OMsg = Nothing
Set OObj = Nothing

End Sub
 

theDBguy

I’m here to help
Staff member
Local time
Today, 01:54
Joined
Oct 29, 2018
Messages
21,471
Hi. Can you show us some before and after sample set of data? Thanks.
 

Users who are viewing this thread

Top Bottom