473,320 Members | 1,861 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Display email in Outlook from Access VBA

AS my users do not want to auto-send an email message generated from within Access 2003, I am using .display instead of .send to show the Outlook message (Word is the Outlook word processor). Can anyone tell me how I can detect whether the "Send" button on the email message was clicked on from within Access VBA?
many thanks in advance, Tony
Nov 23 '11 #1
7 7156
sierra7
446 Expert 256MB
Hi
I don't understand the '.show instead of.' part of your question.

I believe you are generating some kind of report from within Access then using a command button to email it with the Send Object method
Expand|Select|Wrap|Line Numbers
  1. DocCmd.SendObject(ObjectType, ObjectName, OutputFormat, To, Cc, Bcc, Subject, MessageText, EditMessage, TemplateFile)
  2.  
Then I get lost but think you are asking whether the 'Send' button in OutLook has been clicked?

Please give more detail
S7
Nov 23 '11 #2
NeoPa
32,556 Expert Mod 16PB
Tony, there are various ways to handle such things so, without your code to guide us (or a very much better description of your situation) we cannot be of much help to you at this time.

In Outlook there should be an object reflecting the email created. With a reference to that object you can check the Date/Time sent. If the email hasn't been sent yet then it won't be set. More detailed assistance depends heavily on details we don't yet have ;-)
Nov 23 '11 #3
Thanks both for your replies. My code is like this :-

Expand|Select|Wrap|Line Numbers
  1.         Set olApp = Outlook.Application
  2.  
  3.         Set objMail = olApp.CreateItem(olMailItem)
  4.  
  5.  
  6.         objMail.To = "email address"
  7.  
  8.         objMail.Subject = "My Subject"
  9.         objMail.Body = "Body Text"
  10.         objMail.Display     ' Here Objmail.display instead of objmail.send
At this point an Outlook Email Message is displayed so the the users can then decide to send it by clicking the "Send" button or not send it by closing the message. I would like to be able to determine which action was done so that I can update other indicators to reflect Email Sent & Date & Time sent etc. So, the question I am asking is How do I detect that? NeoPa has now got me thinking whether I can check Date/Time sent.....
I hope this is a bit clearer...
Nov 23 '11 #4
NeoPa
32,556 Expert Mod 16PB
Ah. You don't really mean 'How do I detect that?', but rather 'How do I capture that event?'. There is a very real difference, as when the code gets control back the message is still open. At this point your code will then complete execution to allow the operator again to take control. Until another event triggers your code doesn't know anything and cannot even check any status.

The difficulty here is that, while you can handle events such as closing an Inspector window (Items are shown in Inspector windows btw), within Outlook, I'm not sure how that might be achieved from outside of Outlook.

If it's the same them you'd need to define your MailItem properly as :
Expand|Select|Wrap|Line Numbers
  1. Private WithEvents VBAItem As MailItem
This will give you access to events for this item of both Close and Send.

Expand|Select|Wrap|Line Numbers
  1. Private Sub VBAItem_Close(Cancel As Boolean)
  2. End Sub
  3.  
  4. Private Sub VBAItem_Send(Cancel As Boolean)
  5. End Sub
You can then recognise what happens - all assuming this method of handling events is supported outside of Outlook.

PS. Please see [code] Tags Must be Used & When Posting (VBA or SQL) Code.
Nov 24 '11 #5
Thanks NeoPa. It looks like it can be done by using a Class module. I have chosen a slightly simpler method which works fine i.e. having formed the Email detail, I pop up a Msgbox with all details, allowing the users a Yes/No to send or not send.
Now the only little problem I have is the annoying message that "a program is trying to send an e-mail message on your behalf etc...". Do you know of any way I can suppress that message?
thanks again...
Nov 24 '11 #6
NeoPa
32,556 Expert Mod 16PB
'Fraid not Tony. I've read so much about it but I haven't done much in that area and what is out there is frankly so unclear (unless you're deep into the practice of it already) that I would suggest you search around and try the various tips out. There are so many different possible scenarios with such things that you need to try things out for your situation before you go with it.
Nov 24 '11 #7
Well I think I have got a workaround... I installed a third party product called Advanced Security for Outlook (an Add-in for Outlook) which lets me "Allow" the send from Access. i.e. it overrides the security warning and remembers the setting. I think this is just relevant to the invocation from within Access, so security in the rest of the system is not compromised
Nov 25 '11 #8

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Devonish | last post by:
I am composing an email with Access VB and then sending it from within Access. Everything works correctly (the email actually goes!) but Outlook ask some irritating questions that the user is...
0
by: Filips Benoit | last post by:
Dear All, How can i email from access and change the from-property of the email. Quotations for a house are made by several salers with an Access-interface on the firms server ( Remote...
2
by: A | last post by:
I am sending email via access. Outlook now blocks me with following message: A program is trying to automatically send e-mail on your behalf. Do you want to allow this. I must click yes for...
1
by: Robert McGregor | last post by:
Hey everyone, I'm trying to email from access and i want email the contents of one field with a subject of another to the owner of a final field. I think i've referred to everything correctly...
3
by: icsupt via AccessMonster.com | last post by:
I would like to send an email from Access. I copied the code from another free website, but it does not do everything I need it to do. I have a series of checkboxes: checkbox1 - when checked,...
10
by: Mike Charney | last post by:
Is there a simple way to send SMTP email from Access VBA? Mike m charney at dunlap hospital dot org
10
by: OdAwG | last post by:
Hello All, Is it possible to send an email from Access? I found a Microsoft article on how to do this but I keep getting an error "RUNTIME ERROR 438" -- Object doesn't support this property or...
4
by: Doc Holiday | last post by:
What is a good way to send emails from Access, other than using Outlook? FMS has an email app for access, but it seems a bit over priced for just sending out emails from Access.
1
by: Mr T | last post by:
I know how to send email from Access and I know how to create a custom form in Outlook. but.... How do I put the email info from Access into the Outlook custom form ??? Dim MyDB As Database Dim...
1
by: favor08 | last post by:
I'm have automated the creation of an email from Access; whic works fine, but the new email doesn't have the user's default signature on it. Is there any way to either have it find the user's...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.