Results 1 to 3 of 3
  1. #1
    Join Date
    Apr 2002
    Location
    Thailand
    Posts
    81

    Question Unanswered: Happy massmailing so close...

    Hi I am buliding a Customer Database. The Marketing department want to be able to massmail their Contacts by "a click of a button"(Sounds familiar?).

    After some good advice frm PracticalProgram, Previous thread, and CodeLibrarian examples I am so close. So close.

    I need to make a list of all [PersonalEmail] addresses of all members of a recordset, separated by a semicolon and then SendObject with "to" set to the created list.

    As it is now it only inserts the semicolons, exactly one for every record in the recordset, perfect in that aspect. However I don´t know how to get the EmailField to come along into the list.

    The bit where I fail looks like this:

    SendString = ""
    Do Until .EOF
    SendString = SendString & ("PersonalEmail") & "; "
    .MoveNext
    Loop

    SendString = Left$(SendString, Len(SendString) - 2)


    The complete code looks like this:

    ---------------------------------------------------------
    Function EmailCONTACTFORM()

    Dim SendString As String
    Dim rstCONTACTFORM As New ADODB.Recordset


    'Open the Recordset to Customers
    rstCONTACTFORM.ActiveConnection = Application.CurrentProject.Connection
    rstCONTACTFORM.CursorType = adOpenKeyset
    rstCONTACTFORM.Open "CONTACTFORM"


    SendString = ""

    If MsgBox("Send Email" & Chr(13) & _
    "to all Contacts using Microsoft Outlook?", 4) = 6 Then

    With rstCONTACTFORM


    Do Until .EOF

    SendString = SendString & ("PersonalEmail") & "; "
    .MoveNext
    Loop

    SendString = Left$(SendString, Len(SendString) - 2)

    DoCmd.SendObject , "", "", _
    [SendString], , , , , False

    End With
    End If

    rstCONTACTFORM.Close

    End Function
    -------------------------------------
    Last edited by Johnny Dove; 04-11-02 at 09:57.

  2. #2
    Join Date
    Nov 2001
    Posts
    336
    Replace

    SendString = SendString & ("PersonalEmail") & "; "

    with

    SendString = SendString & !PersonalEmail & "; "

    Igor

  3. #3
    Join Date
    Apr 2002
    Location
    Thailand
    Posts
    81
    Thanks, I had actually tried your correct syntax earlier but since it didn´t work, beacause of an other, then unknown error, I changed it to every possible format I could think of.

    Knowing the correct syntax thanks to you, for certain, helped me move on and find the real, but extremely tiny, culprit - The space after the semi-colon. It had to be removed. It has to be like this:

    SendString = SendString & !EmailFieldName & ";"

    Now it works like a charm. Thanks again!

    Complete working code for creating a new, empty mail in your default mapi emailer with a list of correctly formated emailadresses, from your contact table or query, in the "To" -field reads as follows:


    _______________

    Option Compare Database
    Public SendString As String
    _______________

    Function EmailCONTACTS()


    Dim rstYourContactTableOrQuery As New ADODB.Recordset


    'Open the Recordset to Customers
    rstYourContactTableOrQuery.ActiveConnection = Application.CurrentProject.Connection
    rstYourContactTableOrQuery.CursorType = adOpenKeyset
    rstYourContactTableOrQuery.Open "YourContactTableOrQuery "


    SendString = ""

    If MsgBox("Send Email to all Contacts" & Chr(13) & _
    "using Deafault Mapi Mailer?", 4) = 6 Then

    With rstYourContactTableOrQuery


    Do Until .EOF


    SendString = SendString & !EmailFieldName & ";"
    .MoveNext
    Loop

    SendString = Left$(SendString, Len(SendString) - 2)


    DoCmd.SendObject , "", "", [SendString], "", "", "", "", True, ""

    End With
    End If

    rstYourContactTableOrQuery.Close

    End Function
    ___________________

    Do you collect happy endings like this somewhere? Would be nice with a little code-library of solved problems!

    Jo´

    PS Now to the next phase. How on earth do I get a recordset from a user-custom-filtered form? I´ll start up yet a new thread since this is an other issue that can be used for other purposes. DS
    Last edited by Johnny Dove; 04-11-02 at 14:35.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •