Results 1 to 4 of 4
  1. #1
    MarkWF is offline Novice
    Windows 10 Access 2010 64bit
    Join Date
    Aug 2022
    Posts
    1

    Email to text

    Hi everyone.
    I am trying to send email to text via outlook. I have a list of numbers which need a suffix as in the code below. The problem is that the suffix is only added to the last number instead of all numbers.
    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

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,524
    It looks correct, what result are you getting?

    I would think you need the '@voda.co.za' on EVERY email name.

  3. #3
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    4,914
    Put your code within code tags (see my sig), that preseves indentation and makes code easier to read.
    I would put the ; at the end, Outlook does not complain if an email address does not follow that character.
    I would also change the names so as not to get confused. strEmailTo = strEmailTo & ![PersonalContactNumber] & ";"

    As mentioned you need the domain added on each email address if that is the correct domain.?

    Walking through your code with F8 would show that immediately?
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  4. #4
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    4,914
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Switching text box for HTML Email
    By DMT Dave in forum Access
    Replies: 5
    Last Post: 02-11-2022, 01:39 AM
  2. Copy Email to Text box
    By DMT Dave in forum Access
    Replies: 1
    Last Post: 04-25-2019, 02:19 AM
  3. Sending custom text in email
    By fletcjas in forum Programming
    Replies: 5
    Last Post: 09-17-2018, 05:03 PM
  4. Text formatting in email
    By Thompyt in forum Programming
    Replies: 1
    Last Post: 08-11-2016, 03:19 PM
  5. SendObject Email HTML Text
    By abodi in forum Programming
    Replies: 1
    Last Post: 09-10-2014, 12:03 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums