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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

DoCmd.SendObject only works once in a loop!

Status
Not open for further replies.

WynneSMI

Programmer
Dec 16, 2002
76
US
For some reason, I can only get the DoCmd.SendObject to work only once, the very first time, in a loop. Why is this? It goes to the command, but doesn't generate anything. How do I fix this? Thanks.
 
Check out the thread: thread702-304121

The code below is from GammelNok (Hans) and it works great:

Dim objOutLook As Outlook.Application
Dim objNameSpace As Outlook.NameSpace
Dim objMailItem As Outlook.MailItem

Dim strSendTo As String
Dim strSubject As String
Dim strText As String

'======================================================
Set objOutLook = New Outlook.Application
Set objNameSpace = objOutLook.GetNamespace("MAPI")
Set objMailItem = objOutLook.CreateItem(olMailItem)

strSendTo = "xxxx.yyyy@zzz.co.uk"
strSubject = "Test01"
strText = "Hi. Your request processed as requested"

With objMailItem
.To = strSendTo
.Subject = strSubject
.Body = strText
.Send
End With

Set objOutLook = Nothing
Set objNameSpace = Nothing
Set objMailItem = Nothing
end sub

My docmd.sendobject worked fine in Access97.
But it didn't work in Access2000.

So I tried Microsoft's solution at:

That solution worked ok, but, each time, i got a pop up message from Outlook: "a program is trying to access email addresses you have stored in Outlook. Do you want to allow this? If this is unexpected, it may be a virus and you should choose no."

But the way above works great!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top