i have a function created for simple emailing (posted below). i'm new to arrays. i actually figured out how to set up the last value (Att) as an array so i could add an unlimited amount of attachments. now, i'm wondering how i could do the same for the MsgTo variable so i can add an unlimited amount of recipients. will i have to create a separate array function that will be used in the MsgTo value slot? here's my code:
Code:
Option Compare Database
Function EmailMsgTo(MsgTo As String, MsgFrom As String, MsgSubject As String, _
MsgBodyHTMLSite As String, MsgBodyHTMLfile As String, MsgBodyText As String, _
ParamArray Att() As Variant)
Const cdoSendUsingPickup = 1
Const cdoSendUsingPort = 2 'Must use this to use Delivery Notification
Const cdoAnonymous = 0
Const cdoBasic = 1 ' clear text
Const cdoNTLM = 2 'NTLM
'Delivery Status Notifications
Const cdoDSNDefault = 0 'None
Const cdoDSNNever = 1 'None
Const cdoDSNFailure = 2 'Failure
Const cdoDSNSuccess = 4 'Success
Const cdoDSNDelay = 8 'Delay
Const cdoDSNSuccessFailOrDelay = 14 'Success, failure or delay
Dim i As Integer
Set objmsg = CreateObject("CDO.Message")
Set objConf = CreateObject("CDO.Configuration")
Set objFlds = objConf.Fields
With objFlds
.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = cdoSendUsingPort
'Name or IP of Remote SMTP Server
.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "******************"
'Type of authentication, NONE, Basic (Base64 encoded), NTLM
.Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = cdoBasic
'Your UserID on the SMTP server
.Item("http://schemas.microsoft.com/cdo/configuration/sendusername") = "***************@*********"
'Your password on the SMTP server
.Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "********************"
'Server port (typically 25)
.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 465
'Use SSL for the connection (False or True)
.Item("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = True
'Connection Timeout in seconds (the maximum time CDO will try to establish a connection to the SMTP server)
.Item("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 60
.Update
End With
With objmsg
Set .Configuration = objConf
.To = MsgTo
.From = MsgFrom
.Subject = MsgSubject
If MsgBodyHTMLSite <> "" Then
.CreateMHTMLBody MsgBodyHTMLSite
GoTo SendMsg
End If
If MsgBodyHTMLfile <> "" Then
.htmlBody = MsgBodyHTMLfile
GoTo SendMsg
End If
If MsgBodyText <> "" Then
.TextBody = MsgBodyText
GoTo SendMsg
End If
SendMsg:
For i = LBound(Att) To UBound(Att)
objmsg.addattachment Att(i)
Next i
.Fields("urn:schemas:mailheader:disposition-notification-to") = MsgFrom
.Fields("urn:schemas:mailheader:return-receipt-to") = MsgFrom
.DSNOptions = cdoDSNSuccessFailOrDelay
.Fields.Update
.Send
End With
End Function



Comment