?
Solved

Problem sending email from form in Access 2007 vb (DoCmd.SendObject)

Posted on 2008-11-17
8
Medium Priority
?
982 Views
Last Modified: 2013-11-28
Hi,
We've upgraded from Access 2003 to 2007 and I'm having problems with a vb function sending emails from an Access form. Everything works fine - it opens the email box in Outlook, when I click on "send email" in Outlook it sends it immediately, BUT it doesn't close the email window. All commands in the window are disabled, if I wait about 20 seconds it closes itself, or I can click on the close button.
This never used to happen in 2003, when I sent the email the email window would close.
What am I doing wrong?
0
Comment
Question by:GoCellular_ca
  • 4
  • 2
  • 2
8 Comments
 
LVL 85
ID: 22981706
Any other code running other than the SendObject? Can you post the full SendObject call?
0
 
LVL 13

Expert Comment

by:game-master
ID: 22982401


good afternoon!

can u post ur code of sending email.


game-master
0
 
LVL 13

Expert Comment

by:game-master
ID: 22982436

try this approach!


sub Send
    Dim objMsg As Object
    Dim objConfi As Object
    Dim strBody As String
   
    Set objMsg = CreateObject("CDO.Message")
    Set objConfi = CreateObject("CDO.Configuration")
   
    With objMsg
        Set .configuration = objConfi
        .to = <receiver>
        .from = <sender>
        .Subject = "Test"
        .textbody = "This is a test message only."
        .send
    End With
   
    MsgBox "OK"
end sub
0
NEW Veeam Agent for Microsoft Windows

Backup and recover physical and cloud-based servers and workstations, as well as endpoint devices that belong to remote users. Avoid downtime and data loss quickly and easily for Windows-based physical or public cloud-based workloads!

 

Author Comment

by:GoCellular_ca
ID: 22987414
game-master:
 Thanks for the tip, but with your code I'm getting the error "Runtime Error -2147220960 (80040220) The SendUsing configuration is invalid"

LSMConsulting:
No, there's no code running apart from this:
DoCmd.SendObject acSendNoObject, , acFormatRTF, strRecipient, , , strRegarding, strBodyText, True

strRecipient, strRegarding and strBodyText are all simple text strings - I've tried writing recipient etc. directly in the DoCmd.SendObject line but it makes no difference.
I"m beginning to think that this might be a problem with Outlook 2007 instead of a local problem in Access?
0
 
LVL 85
ID: 22987546
SendObject does nothing more than open the message in Outlook (or whatever your default email client happens to be). Once this happens, processing is passed to Outlook. If you have code running after this line (add a MsgBox to verify this), that code will fire immediately - which indicates that Access has passed the object to Outlook and returned to it's own code duties.

As to why this worked in 03 - I've never had it work this way. If I use SendObject with the Show argument set to True, then Outlook would open my message and wait for me to do something with it, but it wouldn't close. As I've said many times before 2007 is much more picky about code and such, and many things that worked in earlier versions have been fixed (for right or wrong) in 2007. Access should have never had any control over the email client simply by calling SendObject ... it would be different if you were actually automating your client, but SendObject does nothing more than add an email to the Outbox of the email client - nothing more. The Show argument (i.e. the one you set True to view the message) simply showed the message and allowed you to interact with it.
0
 
LVL 13

Accepted Solution

by:
game-master earned 2000 total points
ID: 22990603


good morning!

i will give u this link that will show you codes and help on how to send
email using different methods... i hope u can see this knowledgable.

http://www.rondebruin.nl/sendmail.htm

U can also download the excel here which has the code...


I hope i could help you...

game-master

0
 

Author Comment

by:GoCellular_ca
ID: 22990814
@game-master: works perfectly, thank-you very much for your help!
0
 
LVL 13

Expert Comment

by:game-master
ID: 22990887


good morning!

Im glad i could help..


game-master
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Did you know that more than 4 billion data records have been recorded as lost or stolen since 2013? It was a staggering number brought to our attention during last week’s ManageEngine webinar, where attendees received a comprehensive look at the ma…
Traditionally, the method to display pictures in Access forms and reports is to first download them from URLs to a folder, record the path in a table and then let the form or report pull the pictures from that folder. But why not let Windows retr…
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…
Suggested Courses

862 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question