Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.databases.ms-access > #9975
| From | Norman Peelman <npeelman@cfl.rr.com> |
|---|---|
| Newsgroups | comp.databases.ms-access |
| Subject | Re: Access 2013 and sending an email. |
| Date | 2014-10-04 08:58 -0400 |
| Organization | A noiseless patient Spider |
| Message-ID | <m0oqu6$5gl$1@dont-email.me> (permalink) |
| References | <076e8a04-1f71-4d6a-a933-357b195bf2b0@googlegroups.com> <m0kog6$r5g$1@dont-email.me> <f80ba586-b82a-408e-aa42-a5325ef72768@googlegroups.com> |
On 10/03/2014 09:06 AM, Patrick Finucane wrote:
> On Thursday, October 2, 2014 7:52:36 PM UTC-4, Norman Peelman wrote:
>> On 10/02/2014 01:59 PM, Patrick Finucane wrote:
>>
>>> I'm getting something goofy when I automate an email from Access 2013. Outlook is not open at this point. I press a command button on the form to send an email. The code assigns the email elements (Subject, attachment, To, etc) correctly and displays the email prior to sending. All is good at this point. I then press the SEND buttonin Outlook and the email closes. My code looks like this
>>
>>> If DisplayEmail Then
>>
>>> .Display
>>
>>> Else
>>
>>> .Save
>>
>>> .Send
>>
>>> End If
>>
>>>
>>
>>> After pressing the Send button in Outlook, the Outlook email message is closed. I am sending the message to myself for testing. I will wait forever and no message appears in my inbox. The message will ONLY appear when I open up Outlook. It seems doing so releases the message.
>>
>>>
>>
>>> How can I send an email when Outlook is closed initially? I assume I don't have a property setting set correctly.
>>
>>>
>>
>>
>>
>> If Outlook isn't open then how will you see the Inbox? I think
>>
>> you'll find that your email is being sent just fine. You are only
>>
>> dealing with the *new message* window at this point. And unless you have
>>
>> certain security features turned off, you may find that your ELSE
>>
>> statement fails on the .Send command.
>>
>>
>>
>>
>>
>> --
>>
>> Norman
>>
>> Registered Linux user #461062
>>
>> AMD64X2 6400+ Ubuntu 10.04 64bit
>
> OK. I send the message to my GMail account. I send it via Outlook. I have my web browser opened to Gmail. I can wait an hour or two and no msg. When I open Outlook, I get the msg in Gmail immediately.
>
> What surprises me is that I thought .Display made the process Modal and would stop until sent or canceled but the code after .Display just kept on chugging away.
>
Patrick,
Try:
.Display True
first... to make the pop-up modal, then take a look at the:
.Sent
property. Read only. Should be 0 once the email has been sent. Something
along the lines of:
Dim breakout As Long
Dim answer As Integer
breakout = 1
Do While objOutlookMsg.Sent = 1
DoEvents
'wait 1 second
Application.Wait(Now + #0:00:01#)
'count 10 seconds
breakout = breakout + 1
If (breakout = 10) Then
answer = MsgBox("Email has not been sent yet!" & vbCrLf & "Continue
waiting?", vbYesNo + vbExclamation +
vbDefaultButton1 + vbApplicationModal +
vbMsgBoxSetForeground, "Email pending.")
If (answer = vbNo) Then
' do not want to keep waiting... get out of the loop
MsgBox "Please send the email manually.", vbOkOnly + vbCritical +
vbApplicationModal + vbMsgBoxSetForeground, "Email
pending."
Exit Do
Else
'want to keep waiting... reset counter to 1 and wait again.
breakout = 1
End If
Loop
Completely untested but should move you in the right direction. The
idea is that this code would wait for the email to be sent whether it
was sent by .Send or by manually clicking the Send button with an alert
every 10 seconds. There are no *continuation* lines so sorry if the
formatting is messed up (formatted for readability here.) If you use
this code, verify the value of .Sent (MsgBox objOutlookMsg.Sent) prior
to .Send in your current code before adding this code. I'm thinking it
should be equal to 1 (non-zero?) but I could have it backwards. I
deleted my original code because I could not use .Send due to security
warnings.
--
Norman
Registered Linux user #461062
AMD64X2 6400+ Ubuntu 10.04 64bit
Back to comp.databases.ms-access | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Access 2013 and sending an email. Patrick Finucane <patrickfinucanetx@gmail.com> - 2014-10-02 10:59 -0700
Re: Access 2013 and sending an email. Norman Peelman <npeelman@cfl.rr.com> - 2014-10-02 19:52 -0400
Re: Access 2013 and sending an email. Patrick Finucane <patrickfinucanetx@gmail.com> - 2014-10-03 06:06 -0700
Re: Access 2013 and sending an email. Norman Peelman <npeelman@cfl.rr.com> - 2014-10-04 08:58 -0400
Re: Access 2013 and sending an email. Patrick Finucane <patrickfinucanetx@gmail.com> - 2014-10-06 06:25 -0700
Re: Access 2013 and sending an email. JB Guernsey <jeff@angelsystems.co.uk> - 2014-10-06 07:58 -0700
Re: Access 2013 and sending an email. Patrick Finucane <patrickfinucanetx@gmail.com> - 2014-10-06 09:27 -0700
Re: Access 2013 and sending an email. JB Guernsey <jeff@angelsystems.co.uk> - 2014-10-06 10:24 -0700
Re: Access 2013 and sending an email. Patrick Finucane <patrickfinucanetx@gmail.com> - 2014-10-06 10:35 -0700
Re: Access 2013 and sending an email. JB Guernsey <jeff@angelsystems.co.uk> - 2014-10-06 13:19 -0700
Re: Access 2013 and sending an email. Neil <xxx@gmail.com> - 2014-10-03 01:05 -0500
Re: Access 2013 and sending an email. Patrick Finucane <patrickfinucanetx@gmail.com> - 2014-10-03 06:13 -0700
Re: Access 2013 and sending an email. Neil <xxx@gmail.com> - 2014-10-03 14:31 -0500
Re: Access 2013 and sending an email. Patrick Finucane <patrickfinucanetx@gmail.com> - 2014-10-06 06:14 -0700
Re: Access 2013 and sending an email. fmsinc <fmsinc@gmail.com> - 2014-10-10 15:44 -0500
csiph-web