Create long string from query result?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • deko

    #1

    Create long string from query result?

    I'm trying to create an email mailing list for Outlook.

    Here's the part of the sub that puts the email address in the Bcc (or To)
    field:

    With objNewMail
    .BCC = strEmail
    .Display
    End With

    I'm wondering if I can create one long comma-delimited string for "strEmail"
    that is the result of a query.

    .... was also thinking a For loop might work... ???

    any help is greatly appreciated!



  • deko

    #2
    Re: Create long string from query result?

    I think this might work...

    Dim rst As DAO.Recordset
    Set rst = CurrentDb.OpenR ecordset("qryEm ailList")
    Do Until rst.EOF
    strEmail = strEmail & rst!EmailAddres s & ";"
    rst.MoveNext
    Loop
    rst.Close
    Set rst = Nothing


    "deko" <dje422@hotmail .com> wrote in message
    news:92ofb.9191 $TM.2422@newssv r27.news.prodig y.com...[color=blue]
    > I'm trying to create an email mailing list for Outlook.
    >
    > Here's the part of the sub that puts the email address in the Bcc (or To)
    > field:
    >
    > With objNewMail
    > .BCC = strEmail
    > .Display
    > End With
    >
    > I'm wondering if I can create one long comma-delimited string for[/color]
    "strEmail"[color=blue]
    > that is the result of a query.
    >
    > ... was also thinking a For loop might work... ???
    >
    > any help is greatly appreciated!
    >
    >
    >[/color]


    Comment

    • Pieter Linden

      #3
      Re: Create long string from query result?

      "deko" <dje422@hotmail .com> wrote in message news:<3Hofb.114 02$sQ5.10357@ne wssvr25.news.pr odigy.com>...[color=blue]
      > I think this might work...
      >
      > Dim rst As DAO.Recordset
      > Set rst = CurrentDb.OpenR ecordset("qryEm ailList")
      > Do Until rst.EOF
      > strEmail = strEmail & rst!EmailAddres s & ";"
      > rst.MoveNext
      > Loop
      > rst.Close
      > Set rst = Nothing
      >[/color]
      Yes, you could either do that or just add the address to the
      Recipients collection (any of Cc, Bcc, or To) BTW, I think your
      strEMail line should be

      Do Until rst.EOF
      strEMail = strEMail & ";" rst!EMailAddres s
      rst.MoveNext
      Loop
      rst.Close
      set rst=nothing

      strEMail = right$(strEMail ,Len$(strEMail)-1)) ... cuts off the first ;

      Comment

      • deko

        #4
        Re: Create long string from query result?

        thanks for the tip.

        I tried adding each email to the Bcc collection - but couldn't for some
        reason. that's why I resorted to this method...

        "Pieter Linden" <pietlinden@hot mail.com> wrote in message
        news:bf31e41b.0 310040614.3ac4f e66@posting.goo gle.com...[color=blue]
        > "deko" <dje422@hotmail .com> wrote in message[/color]
        news:<3Hofb.114 02$sQ5.10357@ne wssvr25.news.pr odigy.com>...[color=blue][color=green]
        > > I think this might work...
        > >
        > > Dim rst As DAO.Recordset
        > > Set rst = CurrentDb.OpenR ecordset("qryEm ailList")
        > > Do Until rst.EOF
        > > strEmail = strEmail & rst!EmailAddres s & ";"
        > > rst.MoveNext
        > > Loop
        > > rst.Close
        > > Set rst = Nothing
        > >[/color]
        > Yes, you could either do that or just add the address to the
        > Recipients collection (any of Cc, Bcc, or To) BTW, I think your
        > strEMail line should be
        >
        > Do Until rst.EOF
        > strEMail = strEMail & ";" rst!EMailAddres s
        > rst.MoveNext
        > Loop
        > rst.Close
        > set rst=nothing
        >
        > strEMail = right$(strEMail ,Len$(strEMail)-1)) ... cuts off the first ;[/color]


        Comment

        Working...