Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > Access
Password Reminder
Register
| FAQ | Members List | Calendar | 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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #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
Reply With Quote
  #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
Reply With Quote
  #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
Reply With Quote
  #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.
Reply With Quote
  #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
Reply With Quote
  #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
Reply With Quote
  #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
Reply With Quote
  #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
Reply With Quote
  #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
Reply With Quote
  #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

Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


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



All times are GMT -4. The time now is 07:20 PM.


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