Hi,
I have a procedure to send the same email to a selection of people. The procedure works ... almost. Whilst testing it, using breakpoints, all was well, but when run 'live', only one email message is created. The addressees in it are successively overwritten, so I end up with just the last batch of people. The following is an abridged verison of the code:
Dim olApp As Outlook.Application
Dim olMail As Outlook.MailItem
Dim EmailAdds As String
Set olApp = CreateObject("Outlook.Application")
Set olMail = olApp.CreateItem(olMailItem)
olMail.Subject = "Subject"
olMail.BodyFormat = olFormatHTML
' Email message text is in G_Email_Text
olMail.Body = G_Email_Text
' Loop to put first 50 email addresses in EmailAdds
olMail.To = "Undisclosed"
olMail.BCC = EmailAdds
olMail.Display
' Loop back for next batch
By way of explanation:
I don't want to try sending all the copies at once, as there are currently over 200 and this number will increase, hence the 'batch' approach.
I use "Display", rather than "Send" because a) I need to amend the account from which the email is sent [it's not the default account and amending the 'SendAddress' within Access isn't allowed] and b) it avoids the warning message you get with "Send".
I did consider using something like Send Personally, which would avoid this problem, but it would fill up my 'Sent Items' folder, and whilst I do want to retain a copy of the email and the addressees, I don't want 200 and more copies of each email.
I've tried 'DoEvents', which I've seen mentioned elsewhere on this forum, but to no avail.
I can get over the problem by putting a MsgBox immediately after the "olMail.Display", and that's what I will do if no-one can offer me a more elegant solution.
Thanks in anticipation!
I have a procedure to send the same email to a selection of people. The procedure works ... almost. Whilst testing it, using breakpoints, all was well, but when run 'live', only one email message is created. The addressees in it are successively overwritten, so I end up with just the last batch of people. The following is an abridged verison of the code:
Dim olApp As Outlook.Application
Dim olMail As Outlook.MailItem
Dim EmailAdds As String
Set olApp = CreateObject("Outlook.Application")
Set olMail = olApp.CreateItem(olMailItem)
olMail.Subject = "Subject"
olMail.BodyFormat = olFormatHTML
' Email message text is in G_Email_Text
olMail.Body = G_Email_Text
' Loop to put first 50 email addresses in EmailAdds
olMail.To = "Undisclosed"
olMail.BCC = EmailAdds
olMail.Display
' Loop back for next batch
By way of explanation:
I don't want to try sending all the copies at once, as there are currently over 200 and this number will increase, hence the 'batch' approach.
I use "Display", rather than "Send" because a) I need to amend the account from which the email is sent [it's not the default account and amending the 'SendAddress' within Access isn't allowed] and b) it avoids the warning message you get with "Send".
I did consider using something like Send Personally, which would avoid this problem, but it would fill up my 'Sent Items' folder, and whilst I do want to retain a copy of the email and the addressees, I don't want 200 and more copies of each email.
I've tried 'DoEvents', which I've seen mentioned elsewhere on this forum, but to no avail.
I can get over the problem by putting a MsgBox immediately after the "olMail.Display", and that's what I will do if no-one can offer me a more elegant solution.
Thanks in anticipation!