SendMail pause

Pat
5StarLounger
Posts: 1148
Joined: 08 Feb 2010, 21:27

SendMail pause

Post by Pat »

I have used the subroutine SendMail before and was wondering if it can be made to pause prior to sending so the user can modify it first.

JohnH
3StarLounger
Posts: 287
Joined: 09 Mar 2010, 23:16
Location: Canberra Australia

Re: SendMail pause

Post by JohnH »

Does this use SendObject? If so the last parameter in a SendObject command is "EditMessage" and takes either true or false.
Regards

John

Pat
5StarLounger
Posts: 1148
Joined: 08 Feb 2010, 21:27

Re: SendMail pause

Post by Pat »

No it doesn't use SendObject, it uses Outlook automation.

JohnH
3StarLounger
Posts: 287
Joined: 09 Mar 2010, 23:16
Location: Canberra Australia

Re: SendMail pause

Post by JohnH »

for Automation change .Send to .Display
Regards

John

Pat
5StarLounger
Posts: 1148
Joined: 08 Feb 2010, 21:27

Re: SendMail pause

Post by Pat »

Thanks John, I'll try that.

Just tried it, and the Outlook security message pops up, i click on allow to send,it momentarily shows the email then it disappears. There is no instance of the email and its not in the Outbox or Sent folder.
Any ideas?

Maybe the following at the end of the function closes it before i can get to send it manually?

Code: Select all

    ' Release object memory
    On Error Resume Next
    If Not (objMI Is Nothing) Then objMI.close olDiscard
    Set objMI = Nothing
    If blnNotActive And Not (objOL Is Nothing) Then objOL.Quit
    Set objOL = Nothing
    SysCmd acSysCmdClearStatus
    DoCmd.Hourglass False
    Exit Function

JohnH
3StarLounger
Posts: 287
Joined: 09 Mar 2010, 23:16
Location: Canberra Australia

Re: SendMail pause

Post by JohnH »

I am not familiar with the code you are using...but in the version I use there are two instances of .Send (or .Display) at different points.

I have had problems in the past when I change one but not the other.
What version of Office are you using?

Added later:
I did not notice the code when I posted this message. I think your explanation looks correct. I would see what happens without those lines.
Last edited by JohnH on 21 Oct 2010, 04:45, edited 1 time in total.
Regards

John

Pat
5StarLounger
Posts: 1148
Joined: 08 Feb 2010, 21:27

Re: SendMail pause

Post by Pat »

2003.
That code above releases Outlook from memory and so the user doesn't get a chance to change anything. If i omit that code it works fine, although it would leave those object variables in memory.
How would I test if the Email has been sent, I presume that if i know that i can then execute that code.

JohnH
3StarLounger
Posts: 287
Joined: 09 Mar 2010, 23:16
Location: Canberra Australia

Re: SendMail pause

Post by JohnH »

What happens if you just remove this line?

If Not (objMI Is Nothing) Then objMI.close olDiscard


if you set blnNotActive to false then this line would do nothing,
If blnNotActive And Not (objOL Is Nothing) Then objOL.Quit
Regards

John

JohnH
3StarLounger
Posts: 287
Joined: 09 Mar 2010, 23:16
Location: Canberra Australia

Re: SendMail pause

Post by JohnH »

You could add another Parameter to the sendmail function that controls whether you Send it or Display it.
Then modify the code you have displayed to take account of the value of that parameter.
Regards

John

Pat
5StarLounger
Posts: 1148
Joined: 08 Feb 2010, 21:27

Re: SendMail pause

Post by Pat »

I understand but don't need to as the client always wants to have the ability to change the email before it goes out.

User avatar
HansV
Administrator
Posts: 78519
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: SendMail pause

Post by HansV »

As the author of the original version of the code (I posted it in Woody's Lounge years ago), I agree with John: remove (or comment out) the lines

If Not (objMI Is Nothing) Then objMI.close olDiscard

and

If blnNotActive And Not (objOL Is Nothing) Then objOL.Quit

to prevent the e-mail from disappearing immediately after it is displayed.
Best wishes,
Hans

Pat
5StarLounger
Posts: 1148
Joined: 08 Feb 2010, 21:27

Re: SendMail pause

Post by Pat »

I know you are the author of the code, thank you for allowing me to use it, it has been extremely helpful.

I did as you and John have suggested and it works just fine.

Again thank you Hans and John.