SendObject - only works once!

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • jBunton
    New Member
    • Feb 2007
    • 1

    SendObject - only works once!

    I am using send object to generate emails BUT it works once then not again until I close and reopen my application.

    Thus in the code below only 1 email is generated - doesn't matter which of the docmd.SendObjec t lines comes first. Repeat the function - no emails generated. Close access, reopen - one email is generated!

    ?? Any suggestions ??

    ** code snippet **
    Code:
       sendTo = "DummyOne1@Blueyonder.co.uk"
             DoCmd.SendObject objectType, objectName, outputformat, "DummyAddressx@Blueyonder.co.uk", sendCc, sendBcc, sendSubject, sendMessage, editmessage, templateFileName
            DoCmd.SendObject objectType, objectName, outputformat, sendTo, sendCc, sendBcc, sendSubject, sendMessage, editmessage, templateFileName
    ** end code **
    Last edited by NeoPa; Mar 1 '07, 02:02 PM. Reason: Tags
  • nico5038
    Recognized Expert Specialist
    • Nov 2006
    • 3080

    #2
    This is a known problem.
    One solution is to switch to work with the MAPI, but this "shell" solution can be used too:
    Code:
    Public Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long
    
    mail_to="abc@your.com"
    mail_cc="abc@your.com"
    mail_sub="The solution in the subject"
    mail_txt = "here's your text " & "%0D" & "%0D"
    mail_txt = mail_txt & "and a second line" & "%0D" & "%0D"
    
    ShellExecute(0&, vbNullString, "mailto:" & mail_to & "?subject=" & mail_sub & "&cc=" & mail_cc & "&body=" & mail_txt, vbNullString, "C:\", 1)
    Nic;o)

    Comment

    • NeoPa
      Recognized Expert Moderator MVP
      • Oct 2006
      • 32634

      #3
      Nico,
      What protocol does ShellExecute use to send the mail?
      I have loads of restrictions for SMTP in my network so I need to know if it will be subject to those restrictions.
      TIA -Adrian.

      PS Is there somewhere I can find more details on it?

      Comment

      • pks00
        Recognized Expert Contributor
        • Oct 2006
        • 280

        #4
        Hi Nico mate, how are ya doing. Its been a while. How is work for you now. Working locally now arent you? Im doing the mega trek now. Working away from home, about 120miles away but takes about 3hrs so I stay overnight, 6hrs a day commuting is just too much

        Anyways, regarding emails, what version Access are you using. Are you using 2003? are you getting those security popups coming up?

        Do you know the smtp address? Have u considered using something like CDO?
        I got sample code for that if u are interested.

        The other alternative is to use outlook automation. Now u would get the security popup if u are using 2003. I can give examples if you like.

        A similar thing to outlook automation but no security popups is redemption http://www.dimastr.com/redemption/

        Comment

        • Denburt
          Recognized Expert Top Contributor
          • Mar 2007
          • 1356

          #5
          For Outlook security warnings you may want to check out this thread.



          I have been in a number of environments where they had things locked down super tight but I have almost always had success with using CDO.

          I wanted to mention that I have used the redemption component also and it can come in handy for some things.

          Comment

          Working...