Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > Access
| Search | Today's Posts | Mark Forums Read
Access Discussion of Microsoft Access database design and programming. See also the forums for Access ASP and Access VBA.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #1 (permalink)  
Old February 1st, 2005, 12:37 AM
Authorized User
 
Join Date: Dec 2004
Location: Las Vegas, NV, USA.
Posts: 48
Thanks: 0
Thanked 0 Times in 0 Posts
Default how to send email to outlool from Access

Hi,
   In the project I worked on, I need to select an email address from a combo box(personID)and sent an email to the selected address.
How can I reach this goal. Thanks for any suggestion!

flyfish
__________________
flyfish
  #2 (permalink)  
Old February 1st, 2005, 04:50 AM
Friend of Wrox
 
Join Date: Jan 2005
Location: , , United Kingdom.
Posts: 100
Thanks: 0
Thanked 0 Times in 0 Posts
Default

You can use the access function SendObject for this (docmd.sendobject)

Jp
  #3 (permalink)  
Old February 1st, 2005, 12:21 PM
Authorized User
 
Join Date: Dec 2004
Location: Las Vegas, NV, USA.
Posts: 48
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Can you give me some details? Thanks!

flyfish
  #4 (permalink)  
Old February 1st, 2005, 12:32 PM
Friend of Wrox
 
Join Date: Jan 2005
Location: , , United Kingdom.
Posts: 100
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Sure, This is a very simple send command, you can elaborate on it further by attaching objects like reports, Copying someone in to the mail, etc. There is even an argument to send the mail without any input from the user.

Private Sub cboPerson_AfterUpdate()
    Dim strAddress As String
    Dim strMsg As String


    strMsg = "This mail is for you" & vbCrLf & "More message text"
    strAddress = cboPerson.Column(1) 'Whatever column you have put the mail address in

    DoCmd.SendObject acSendNoObject, , , strAddress, , , strTitle, strMsg

End Sub

This basically fires after you have chosen the person from your combo box. If you need help on this Try highlighting the SendObject command after you have pasted the function into your module and hitting F1 on your keyboard. The help file for this is quite good and should give you some helpful advice. Any problems give us a shout.
  #5 (permalink)  
Old February 1st, 2005, 12:34 PM
Friend of Wrox
 
Join Date: Jan 2005
Location: , , United Kingdom.
Posts: 100
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Sorry Flyfish, Missed some bits,

Private Sub cboPerson_AfterUpdate()
    Dim strAddress As String
    Dim strMsg As String
    Dim strTitle As String

    strMsg = "This mail is for you" & vbCrLf & "More message text"
    strAddress = cboPerson.Column(1) 'Whatever column you have put the address in
    strTitle = "A message"

    DoCmd.SendObject acSendNoObject, , , strAddress, , , strTitle, strMsg
End Sub
  #6 (permalink)  
Old February 1st, 2005, 01:27 PM
Friend of Wrox
Points: 9,611, Level: 42
Points: 9,611, Level: 42 Points: 9,611, Level: 42 Points: 9,611, Level: 42
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Mar 2004
Location: Washington, DC, USA.
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts
Default

You may run into a problem with Outlook using this method since Outlook tries to protect against processes sending emails (to prevent malware propagation) and may pop up a warning to the user that something is trying to send a message through Outlook.

This method also assumes there is an email client loaded on the machine that is running Access.

mmcdonal
  #7 (permalink)  
Old February 1st, 2005, 01:37 PM
Friend of Wrox
 
Join Date: Jan 2005
Location: , , United Kingdom.
Posts: 100
Thanks: 0
Thanked 0 Times in 0 Posts
Default

You are quite right!
Do you have an alternative method that will allow this? I ask beacuse I have several routines like this already set up. Although users don't have any problems with this method I would like to change them to remove the risk you identified. I forgot the part about trapping the error about the e-mail client. Whoops!

Jp
  #8 (permalink)  
Old February 1st, 2005, 08:40 PM
Authorized User
 
Join Date: Dec 2004
Location: Las Vegas, NV, USA.
Posts: 48
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks for all the discussion. I will try this method tonight and report to here, See you!

flyfish
  #9 (permalink)  
Old February 2nd, 2005, 01:17 AM
Authorized User
 
Join Date: Dec 2004
Location: Las Vegas, NV, USA.
Posts: 48
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi,
   I tried the code, but didn't work for my project.
   In the form, I have two combo boxes as follows:
   1.cboEmployeeName(row source: EmployeeName, EmployeeID, bound to EmployeeID)
   2.cboEmail(row source: EmployeeEmail, EmployeeID, bound to EmployeeID)
   EmployeeName, EmployeeEmail and EmployeeID are in the employee table.

   If I select an employee name from cboEmployeeName, employee's email address will pop up in the cboEmail. Then I click the button(named "sendEmail") I should send this email out. Here is the code in the click event:

Private Sub sendEmail_Click()
   Dim strAddress As String
   Dim strMsg As String
   Dim strTitle As String

   strMsg = "Work order information"

   strAddress = cboEmail.Employee_Email
   strTitle = "A message"
   DoCmd.SendObject acSendNoObject, , , strAddress, , , strTitle, strMsg
End Sub

Here is the error msg I got when I clicked the "sendEmail" button:
"Compile error, Method or data member not found" and highlighs "strAddress = cboEmail.Employee_Email".

Any suggestion?

flyfish
  #10 (permalink)  
Old February 2nd, 2005, 01:35 AM
Friend of Wrox
 
Join Date: Jan 2005
Location: Kansas City, Missouri, USA.
Posts: 471
Thanks: 0
Thanked 1 Time in 1 Post
Default

I'm new to this forum and saw your last message. Since your combo box is bound to the employee id, are your sure you're getting the email value?

Just a thought.

Kevin





Similar Threads
Thread Thread Starter Forum Replies Last Post
How to send email abiye49 Excel VBA 1 January 10th, 2007 03:32 PM
Send by email tsimsha Classic ASP Databases 1 October 1st, 2005 03:03 AM
To send an email Danny_n BOOK: Excel 2003 VBA Programmer's Reference 0 January 12th, 2005 08:33 AM
Send email Danny_n BOOK: Excel 2003 VBA Programmer's Reference 0 January 12th, 2005 08:32 AM
send email X-Ken VS.NET 2002/2003 8 July 2nd, 2004 06:13 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.