Smitty
Legend
- Joined
- May 15, 2003
- Messages
- 29,536
I have a strange issue I can't quite figure out (as usual). I'm using the following Redemption code to send an e-mail from Access without the security prompt:
I have 2 test e-mail addresses in my e-mail table. Now here's what's weird: MsgBox strEMailAddress will iterate through the addresses and return both, but .Recipients.Add strEMailAddress creates two e-mails, as it should, but it only uses the first e-mail address, not the second. I don't see whay the MsgBox would iterate, but not recipients?
Thanks!
Code:
Sub RedemptionEMail()
Dim SafeItem As Object
Dim objOutlook As Object
Dim objNS As Object
Dim olMailItem
Dim objOutlookMsg As Object
Dim strSubject As String
Dim strbody As String
Dim DB As Database
Dim rst As Recordset
Dim strEMailAddress As String
Set DB = CurrentDb
strEMailAddress = "SELECT tbl_REF_EmailAddresses.txt_EMail, tbl_REF_EmailAddresses.cb_MailYesNo " & vbCrLf & _
"FROM tbl_REF_EmailAddresses " & vbCrLf & _
"WHERE (((tbl_REF_EmailAddresses.cb_MailYesNo)=Yes)) " & vbCrLf & _
"ORDER BY tbl_REF_EmailAddresses.txt_EMail;"
Set rst = DB.OpenRecordset(strEMailAddress)
Set SafeItem = CreateObject("Redemption.SafeMailItem")
' create the Outlook session
Set objOutlook = CreateObject("Outlook.Application")
Set objNS = objOutlook.GetNamespace("MAPI")
objNS.Logon
' create the Message
Set objOutlookMsg = objOutlook.CreateItem(olMailItem)
SafeItem.Item = objOutlookMsg
strSubject = "Foo"
strbody = "foo2"
rst.MoveFirst
Do Until rst.EOF
strEMailAddress = rst![txt_EMail]
MsgBox strEMailAddress
With SafeItem
.Recipients.Add strEMailAddress
.Subject = strSubject
.Body = strbody
.Display
'.Save
'.Send
End With
rst.MoveNext
Loop
Set rst = Nothing
Set DB = Nothing
Set objOutlookMsg = Nothing
Set objNS = Nothing
Set objOutlook = Nothing
Set SafeItem = Nothing
End Sub
I have 2 test e-mail addresses in my e-mail table. Now here's what's weird: MsgBox strEMailAddress will iterate through the addresses and return both, but .Recipients.Add strEMailAddress creates two e-mails, as it should, but it only uses the first e-mail address, not the second. I don't see whay the MsgBox would iterate, but not recipients?
Thanks!