[RESOLVED] Sending email to Multiple addresses
I had worked on this eariler. This is my first attempt to use the MAPI control. I have searched the web every site I could find relating to sending multiple emails from VB6 and found many references but little real examples. The following is a modification of one that looked promising and it does just what I want to do EXCEPT, it only send an email to the last name in the array. It doesn't make any difference how many array entries there are only the last one gets a email message.
I would appreciate any assistance to determine why this is.
vb Code:
'Logon & Sync
MAPISession.SignOn
' Create Message w/Attachments then Send
With MAPIMessages
.SessionID = MAPISession.SessionID
.Compose
.MsgSubject = txtSubject
'A value (Spaces)is passed to the Space() function in the
'next line based on the number of attachments to add.
'These spaces act as placeholders for the attachments.
If Trim(txtLocation(0)) <> "" Then Spaces = Spaces + 1
If Trim(txtLocation(1)) <> "" Then Spaces = Spaces + 1
If Spaces <> 0 Then ' there are no attachments to send
.MsgNoteText = Space(Spaces) & vbCrLf '& rtbMessage
'Replace the AttachmentPathName values below as applicable.
.AttachmentIndex = 0
.AttachmentPosition = 0
.AttachmentPathName = Trim(txtLocation(0).Text) ' ("c:\Send email 1.txt")
.AttachmentIndex = 1
.AttachmentPosition = 1
.AttachmentPathName = Trim(txtLocation(1).Text) '("c:\send email 2.txt")
End If
' add the message to the email
.MsgNoteText = .MsgNoteText & txtMessage
.RecipType = 1
For N = 0 To ubound(gsortrec)
.RecipAddress = Trim(gSortRec(N).Email)
.recipindex = 1
Next N
.Send False
MAPISession.SignOff
Re: Sending email to Multiple addresses
it is a long time since i used mapi, but i think you have to add additional recipients to the collection, check the help files
http://support.microsoft.com/kb/153311
Re: Sending email to Multiple addresses
Pete , thanks for the response. Sorry to get back so late but was away the Thhanksgiving.
I tried the sample from the web site you mentioned. It would not work at all. Apparently it was developed involving Microsoft Exchange or other references that I apparently do not have.
I made a revison to simply loop through the gSortRec array and do a send within each loop instead of trying to create a collection of email adresses. This seems to work. I am not sure if the actual processing within the email program itself (Thunderbid) is the same but unless I find a better method I guess that is what I will go with.
Typically, I will be sending around 100 emails each month to members of a club I do a newsletter for.
Thanks again.
Re: [RESOLVED] Sending email to Multiple addresses
This seems to be working for me;
Code:
'The Tos
.RecipIndex = 0
.RecipDisplayName = Recipient$(0)
.RecipAddress = Recipient$(0)
.RecipType = mapToList '1
.RecipIndex = 1
.RecipDisplayName = Recipient$(1)
.RecipAddress = Recipient$(1)
.RecipType = mapToList '1
'The Ccs
.RecipIndex = 2
.RecipDisplayName = Recipient$(2)
.RecipAddress = Recipient$(2)
.RecipType = mapCcList '2
Where Recipient$() is an array of strings containing the email addresses.
Re: [RESOLVED] Sending email to Multiple addresses
This is strange. I copied you example, created an array with mt emial address, added a subject to tell me which email I was getting. I have the same problem I mentioned eariler. Only the last email actually is sent. I added 2 more just to verify this and in every case only the last addressee is sent a email. THe actual codeis:
ReDim Recipient(3) As String
Recipient$(1) = "[email protected]"
Recipient$(2) = "[email protected]"
Recipient$(3) = "[email protected]"
'The Tos
.RecipIndex = 0
.RecipDisplayName = Recipient$(1)
.RecipAddress = Recipient$(1)
.RecipType = mapToList '1
.MsgSubject = "Test " & "1"
.RecipIndex = 1
.RecipDisplayName = Recipient$(2)
.RecipAddress = Recipient$(2)
.RecipType = mapToList '1
.MsgSubject = "Test " & "2"
'The Ccs
.RecipIndex = 2
.RecipDisplayName = Recipient$(3)
.RecipAddress = Recipient$(3)
.RecipType = mapCcList '2
.MsgSubject = "Test " & "3"
.Send False
I have tried looping through and doing a .send false after each email address does work. As I said I don't know if ThunderBird of the email server at RoadRunner treats in any different than doing a snigle send but if I get no clplaints I gues that is the way I will go.
Thanks for the assitance.
Re: [RESOLVED] Sending email to Multiple addresses
You can have multiple Recipients but only one MsgSubject. To test you will need more than one email address. If you do .Send True you will get a preview of the email which should make debug easier.
Re: [RESOLVED] Sending email to Multiple addresses
mapi requires the installation of a mapi compliant email client, typically outlook, or previously windows messaging to work correctly, i do not believe that thunderbird would equate to this
i would be using either vbsendmail or cdo.message to send emails, either of which can send to multiple recipients, cdo is installed with windows xp on and can be installed with some previous versions, can also work with ssl smtp servers, this would currently be my preference, there are many examples in this forum
many outgoing mail servers have restriction on bulk emailing, either quantity of senders per email, # of emails sent in a period, or other methods, to prevent spam, some isp also block port 25, except to their own server
edit: on checking it would appear that thunderbird is mapi compliant