Concatenate string limit

C

Curt

I created a form which allows the user to select the
criteria/group of people they wish to send an email to.
After the selection a macro is used to concatenate the
emails in the To section of Outlook. This all works fine,
but for some reason when it goes through this process the
To: section only allows 255 charaters. Is there a rule
about a string having a limit of 255? I used a
concatenate function I got from some one a couple years.
Thanks for any suggestions

Function Concatenate(pstrSQL As String, _
Optional pstrDelim As String = "; ") As String
Dim db As DAO.Database
Dim rst As DAO.Recordset
Dim strConcat As String 'build return string
Set db = CurrentDb
Set rst = db.OpenRecordset(pstrSQL)
With rst
If Not .EOF Then
.MoveFirst
Do While Not .EOF
strConcat = strConcat & .Fields(0) &
pstrDelim
.MoveNext
Loop
End If
.Close
End With
Set rst = Nothing
Set db = Nothing
If Len(strConcat) > 0 Then
strConcat = Left(strConcat, Len(strConcat) - Len
(pstrDelim))
End If
Concatenate = strConcat
End Function
 
C

Cheryl Fischer

You have not indicated how you are creating your emails; however, if you are
using Outlook Automation, the following code sample will allow you to read
the email address in each record of a form's record source and add it to the
Recipients object of the Mail Item:

Dim oApp As Outlook.Application
Dim objNewMail As Outlook.MailItem
Dim objOutlookRecip As Outlook.Recipient
Dim rs As DAO.Recordset

Set rs = Me.RecordsetClone
Set oApp = New Outlook.Application

Set objNewMail = oApp.CreateItem(olMailItem)
With objNewMail
rs.MoveFirst
Do While Not rs.EOF
If Len(Trim(rs!Email)) > 0 Then
Set objOutlookRecip = .Recipients.Add(rs!Email)
objOutlookRecip.Type = olTo
End If
rs.MoveNext
Loop
.Subject = "Test subject"
.Body = "Your text message here."
.Save
.Send
End With
 
C

Cheryl Fischer

Here are some additional links regarding using Automation with Outlook.
The first one is particularly good for "getting started":

MSDN article on creating appointments, emails, etc., using Automation
http://tinyurl.com/2knwj

Q161088 Using Automation to Send a Microsoft Outlook Message
http://support.microsoft.com/?id=161088

HOW TO: Use Automation to Send a Microsoft Outlook Message using Access 2000
http://support.microsoft.com/?id=209948

ACC97: How to Use a Recordset to Send Outlook E-Mail to Multiple Recipients
http://support.microsoft.com/?id=318881
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top