Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Outlook Sending to mulitple emails from VB

Status
Not open for further replies.

netcashin

Programmer
Nov 13, 2000
159
US
The problem is that we are trying to send to multiple email addresses. We have it stored in a table on a SQL server in the form of 'person1@mail.com; person2@mail.com'. When Outlook opens and tries to send the message only the first person receives the message. Any known bugs about this?
 
Some sample code may help us debug your problem. Here is a function that I use to send a message to up to 6 recipients.
Code:
Public Type eMailInfo
    sTo(6) As String
    Subject As String
    Message As String
End Type
Public eMail As eMailInfo

Public Sub SendMailMessage()
    Dim olApp As Object, olItem As Object, i As Integer, sCCList As String
    Set olApp = CreateObject("Outlook.Application")
    Set olItem = olApp.CreateItem(olMailItem)
    i = 0
    Do While (Len(eMail.sTo(i))) > 0
        olItem.Recipients.Add eMail.sTo(i)
        i = i + 1
    Loop
    olItem.Subject = eMail.Subject
    olItem.Body = eMail.Message
    olItem.DeleteAfterSubmit = True
    olItem.OriginatorDeliveryReportRequested = False
    olItem.ReadReceiptRequested = False
    olItem.Send
    For i = 0 To 5: eMail.sTo(i) = "": Next i       'clear list of addresses
End Sub
To send a message:
Code:
eMail.sTo(0) = "person1@mail.com"
eMail.sTo(1) = "person2@mail.com"
eMail.Subject = "Type the Subject Here"
eMail.Message = "Type the Message Here"
SendMailMessage
 
The last section did not show up correctly. The e-mail addresses should be:

"person1@mail.com"
"person2@mail.com"
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top