473,406 Members | 2,369 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,406 software developers and data experts.

Open blank email from button

Hi there,

I want to have a button on an 'admin' form whereby the user of the database would click the button and a blank email would open in Outlook for the user to enter his/her problem into. But I want the 'to' email address and subject to be already present in the new email.

If the Outlook program is closed, when the user clicks the button I also want Outlook to open and the blank email with subject and 'to' address filled in.


I have the code below but when I click the button it, 1. doesnt open outlook and 2. sends the email without allowing someone to edit it.

Can someone please help!!

Expand|Select|Wrap|Line Numbers
  1. Private Sub cmdemail_Click()
  2.  
  3.     Dim olApp As Object
  4.     Dim objMail As Object
  5.  
  6.     On Error Resume Next 'Keep going if there is an error
  7.     Set olApp = GetObject(, "Outlook.Application")  'this checks if outlook is open
  8.  
  9.         If Error Then 'if outlook is not open then do the following
  10.             Set olApp = CreateObject("Outlook.Application")
  11.         End If
  12.  
  13.     'creating the email item
  14.     Set objMail = olApp.CreateItem(olMailItem)
  15.  
  16.     With objMail
  17.     'then need to set the body the HTML format
  18.         .BodyFormat = olFormatHTML
  19.         .To = "david.everson@reemtsma.de"
  20.         .Subject = "Product Development Ink and Varnish Database Help"
  21.         .HTMLBody = "<htmltags>Thank you for your email. Please include a brief description of your problem below. I aim to respond to all problems within 3 working days</htmltags>"
  22.         .send
  23.     End With
  24.  
  25. End Sub
  26.  
Feb 14 '14 #1
3 7913
ADezii
8,834 Expert 8TB
The following should do the trick for you:
Expand|Select|Wrap|Line Numbers
  1. 'Set a Reference to the Microsoft Outlook XX.X Object Library
  2. Dim oLook As Object
  3. Dim oMail As Object
  4.  
  5. Set oLook = CreateObject("Outlook.Application")
  6. Set oMail = oLook.CreateItem(0)
  7.  
  8. With oMail
  9.  .To = "SomeBody@aol.com"
  10.  .Subject = "Generic Subject"
  11.    .Display
  12. End With
  13.  
  14. Set oMail = Nothing
  15. Set oLook = Nothing
Feb 14 '14 #2
Thats great! Thanks!
Feb 21 '14 #3
ADezii
8,834 Expert 8TB
You are quite welcome.
Feb 21 '14 #4

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

Similar topics

6
by: abcd | last post by:
How to make the make the data given in hyperlink to open the email browser, instead of the internet browser? Thanks. -abcd
3
by: trynittee | last post by:
Hello, Thank you so much in advance to those who will take the time to read and answer. This group is a wonderful site. I have inherited a contacts database that sits on a server. Users...
0
by: ng1 | last post by:
Hello , I am writing in order to get your valuable help . I have been working on a job which involves sending emails thorough Access. I created a form , a very simple one with a few fields to fill...
5
by: erick-flores | last post by:
Hello When my form opens I want to check IF the form was open clicking Button#1 then do something else do something endif Something like: Private Sub Form_Open(Cancel As Integer) If...
1
by: simontindall | last post by:
Hi, I'm working on a database that contains personal details. What I'd like to have is a button next to the records email address that when clicked passes the records email address into the...
1
by: maheswaran | last post by:
Hi all, I need a open source email management software like Microsoft Exchange server Can any one tell me? Thanks in advance
1
by: rakabuku | last post by:
I'm really new with Acces and VBA, so all the help with code is greatly appreciated! I created a form that kind of works like a switchboard (FRM_A) with two combo boxes . Both boxes take the...
3
by: mandeep gill | last post by:
how to open table on button click with search creteria passed? i have a form with two text boxes for search according to name and phone number . i am opening a table on click of button. i...
3
by: ebasshead | last post by:
Hi Everyone, I'm trying to figure out how to reply to an open outlook email via an access button, I've been using VBs docmd.sendobject method in the past to start new emails and attach PDFs, but...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.