create a module with the following.Option Compare DatabaseOption ExplicitPublic Function ReadUntil(ByRef sIn As String, sDelim As String, Optional bCompare As Integer = vbBinaryCompare) As String Dim nPos As String nPos = InStr(1, sIn, sDelim, bCompare) If nPos > 0 Then ReadUntil = Left(sIn, nPos - 1) sIn = Mid(sIn, nPos + Len(sDelim)) End IfEnd Function Public Function Split(ByVal sIn As String, Optional sDelim As String, Optional nLimit As Long = -1, Optional bCompare As Integer = vbBinaryCompare) As VariantDim sRead As String, sOut() As String, nC As Integer If sDelim = "" Then Split = sIn End If sRead = ReadUntil(sIn, sDelim, bCompare) Do ReDim Preserve sOut(nC) sOut(nC) = sRead nC = nC + 1 If nLimit <> -1 And nC >= nLimit Then Exit Do sRead = ReadUntil(sIn, sDelim) Loop While sRead <> "" ReDim Preserve sOut(nC) sOut(nC) = sIn Split = sOutEnd FunctionPublic Function SendOutlookMail(ByVal strSubject As String, ByVal strBody As String, ByVal strRecipients As String, Optional ByVal strAttachments As String = "", Optional ByVal bolPreview As Boolean = False)Dim golApp As ObjectDim objNewMail As ObjectDim Recipients As VariantDim Attachments As VariantDim i As IntegerSet golApp = CreateObject("Outlook.Application")Set objNewMail = golApp.CreateItem(0)objNewMail.Subject = strSubjectobjNewMail.Body = strBodyRecipients = Split(strRecipients, ";")For i = LBound(Recipients) To UBound(Recipients) If Recipients(i) <> "" Then objNewMail.Recipients.Add (Recipients(i)) End IfNextIf strAttachments <> "" Then Attachments = Split(strAttachments, ";") For i = LBound(Attachments) To UBound(Attachments) If Attachments(i) <> "" Then objNewMail.Attachments.Add (Attachments(i)) End If Next End IfIf bolPreview = True Then objNewMail.DisplayElse objNewMail.SendEnd IfSet golApp = NothingSet objNewMail = NothingEnd Function
Now you can use the SendOutlookMail function to email multiple people.All you have to do is pass in a string of Recipients separated by ;."Recipient1@abc.com;Recipient2@abc.com"For Attachments you have to provide the file paths also separated by ;Write a query that returns the names of the people loop over the data and create the recipient string. Feel free to add in CC and BCC.EnjoyEdited by - ValterBorges on 12/28/2002 10:43:06