473,414 Members | 1,711 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,414 software developers and data experts.

Open outlook from Access to send mailto:

116 100+
Please can anyone help.

I am trying to add a button to a form which will pick up an email address, launch outlook, place the address in "Sendto" field and then let me manually type a letter.

I have always used the code below but this only works for sending a message then closing outlook having sent an automated message. I need it to keep outlook open.

I am really a self taught novice at this and only found the code by chance and sure it will be easy for someone with knowledge.

Hope you can assist.

Regards
jacc14


Expand|Select|Wrap|Line Numbers
  1. Private Sub Command9_Click()
  2.  
  3. Dim bStarted As Boolean
  4. Dim oOutlookApp As Outlook.Application
  5. Dim oItem As Outlook.MailItem
  6.  
  7. On Error Resume Next
  8.  
  9.  
  10. 'Get Outlook if it's running
  11. Set oOutlookApp = GetObject(, "Outlook.Application")
  12. If Err <> 0 Then
  13.     'Outlook wasn't running, start it from code
  14.     Set oOutlookApp = CreateObject("Outlook.Application")
  15.     bStarted = True
  16. End If
  17.  
  18. 'Create a new mailitem
  19. Set oItem = oOutlookApp.CreateItem(olMailItem)
  20.  
  21. With oItem
  22.     'Set the recipient for the new email
  23.    .To = "jacc14@testing.co.uk"
  24.  
  25.     .Send
  26. End With
  27.  
  28. If bStarted Then
  29. '    'If we started Outlook from code, then close it
  30.     oOutlookApp.Quit
  31. End If
  32.  
  33. 'Clean up
  34. Set oItem = Nothing
  35. Set oOutlookApp = Nothing
  36.  
  37.  
  38.  
  39. End Sub
Jul 12 '07 #1
5 38493
FishVal
2,653 Expert 2GB
Please can anyone help.

I am trying to add a button to a form which will pick up an email address, launch outlook, place the address in "Sendto" field and then let me manually type a letter.

I have always used the code below but this only works for sending a message then closing outlook having sent an automated message. I need it to keep outlook open.

I am really a self taught novice at this and only found the code by chance and sure it will be easy for someone with knowledge.

Hope you can assist.

Regards
jacc14


Expand|Select|Wrap|Line Numbers
  1. Private Sub Command9_Click()
  2.  
  3. Dim bStarted As Boolean
  4. Dim oOutlookApp As Outlook.Application
  5. Dim oItem As Outlook.MailItem
  6.  
  7. On Error Resume Next
  8.  
  9.  
  10. 'Get Outlook if it's running
  11. Set oOutlookApp = GetObject(, "Outlook.Application")
  12. If Err <> 0 Then
  13.     'Outlook wasn't running, start it from code
  14.     Set oOutlookApp = CreateObject("Outlook.Application")
  15.     bStarted = True
  16. End If
  17.  
  18. 'Create a new mailitem
  19. Set oItem = oOutlookApp.CreateItem(olMailItem)
  20.  
  21. With oItem
  22.     'Set the recipient for the new email
  23.    .To = "jacc14@testing.co.uk"
  24.  
  25.     .Send
  26. End With
  27.  
  28. If bStarted Then
  29. '    'If we started Outlook from code, then close it
  30.     oOutlookApp.Quit
  31. End If
  32.  
  33. 'Clean up
  34. Set oItem = Nothing
  35. Set oOutlookApp = Nothing
  36.  
  37.  
  38.  
  39. End Sub
Hi!

There is no need to write comprehensive code. Simply use
Expand|Select|Wrap|Line Numbers
  1.  FollowHyperlink "mailto:[mail address]"
Good luck.
Jul 13 '07 #2
jacc14
116 100+
Hi there.
Cant believe it. Just tried it and its so simple.

Many thanks

Jacc14
Jul 13 '07 #3
FollowHyperlink "mailto:[mail address]"
Assuming [mail address] is the name of the control. My control name is ContactEmail. I changed it to this and it does not work for me. I have Access 2007. I get an error about communicating with the OLE server or Active X control.
Apr 7 '09 #4
ChipR
1,287 Expert 1GB
Change
Expand|Select|Wrap|Line Numbers
  1. .Send
to
Expand|Select|Wrap|Line Numbers
  1. .Display
Apr 8 '09 #5
ChipR
1,287 Expert 1GB
Or,
Expand|Select|Wrap|Line Numbers
  1. FollowHyperlink "mailto: " & [mail address]
Apr 8 '09 #6

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

Similar topics

1
by: deko | last post by:
Does this code look correct? Private Sub cmdCalendar_Click() Dim mOutlookApp As Outlook.Application Dim mNameSpace As Outlook.NameSpace Set mOutlookApp = New Outlook.Application Set mNameSpace...
4
by: PerryC | last post by:
All, How to ensure SendObject open Outlook and Not Outlook Express? Most pc here at work will default to open OL but on one pc, it open up OL Express. How to fix this in the code? P.S.: I...
2
by: Ivan Weiss | last post by:
I am trying to send a test e-mail through my program using Outlook so that I know my code works and I can submit office forms through e-mail instead of paper. Here is my code: Dim objOutlook As...
14
by: C | last post by:
Hi, From my ASP.NET application when the user clicksa button I want to be able to programmatically open Outlook, create a new mail, add attachments and set the body text. Is this possible? ...
3
by: ConfusedMay | last post by:
Hi, I've created an access 2003 database that has a form with button called "open complaint database." This complaint database is also in access 2003. Here is my code to open the complaint...
3
by: getro | last post by:
Hi Everyone, I need to open an Access 2003 form to a specific record from a custom Outlook 2003 Appointment form. The form has a command button that would pass a record id to access and open the...
23
by: andyoye | last post by:
How can I launch Outlook on users machines when they click a button on a web form (InfoPath)? Thanks
2
by: jrworsham | last post by:
Please help! I have an Outlook module opening a connection to Access, writing in some data, and then pulling out some data. But for some reason the code only works the first time and after that you...
1
by: Matt Tonkin | last post by:
Hi: I need to automate outlook to send an email to me when my Outlook calendar is updated but i am not at my desk. I have written a code that will compile and tabulate my calendar for the day, place...
1
by: Dean Kemp | last post by:
Hi I have designed a button that sends a mail “automated” by the system. But it doesn’t work if outlook is closed. And I have a string of code that opens outlook but then it opens on top of my app....
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
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...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

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.