Connecting Tech Pros Worldwide Forums | Help | Site Map

SendObject - only works once!

Newbie
 
Join Date: Feb 2007
Location: uk
Posts: 1
#1: Feb 28 '07
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.SendObject lines comes first. Repeat the function - no emails generated. Close access, reopen - one email is generated!

?? Any suggestions ??

** code snippet **
Expand|Select|Wrap|Line Numbers
  1.    sendTo = "DummyOne1@Blueyonder.co.uk"
  2.          DoCmd.SendObject objectType, objectName, outputformat, "DummyAddressx@Blueyonder.co.uk", sendCc, sendBcc, sendSubject, sendMessage, editmessage, templateFileName
  3.         DoCmd.SendObject objectType, objectName, outputformat, sendTo, sendCc, sendBcc, sendSubject, sendMessage, editmessage, templateFileName
** end code **

nico5038's Avatar
Moderator
 
Join Date: Nov 2006
Location: The Netherlands
Posts: 2,469
#2: Feb 28 '07

re: SendObject - only works once!


This is a known problem.
One solution is to switch to work with the MAPI, but this "shell" solution can be used too:
Expand|Select|Wrap|Line Numbers
  1. 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
  2.  
  3. mail_to="abc@your.com"
  4. mail_cc="abc@your.com"
  5. mail_sub="The solution in the subject"
  6. mail_txt = "here's your text " & "%0D" & "%0D"
  7. mail_txt = mail_txt & "and a second line" & "%0D" & "%0D"
  8.  
  9. ShellExecute(0&, vbNullString, "mailto:" & mail_to & "?subject=" & mail_sub & "&cc=" & mail_cc & "&body=" & mail_txt, vbNullString, "C:\", 1)
  10.  
Nic;o)
NeoPa's Avatar
Administrator
 
Join Date: Oct 2006
Location: London - UK
Posts: 16,173
#3: Apr 11 '07

re: SendObject - only works once!


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?
pks00's Avatar
Expert
 
Join Date: Oct 2006
Posts: 281
#4: Apr 11 '07

re: SendObject - only works once!


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/
Denburt's Avatar
Moderator
 
Join Date: Mar 2007
Location: Louisiana
Posts: 1,218
#5: Apr 11 '07

re: SendObject - only works once!


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

http://www.thescripts.com/forum/thre...8740-2-10.html

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.
Reply


Similar Microsoft Access / VBA bytes