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

Sending an Outlook Email Message from Access Database

I have a database that is tracking drawing markups from our manufacturing shop. The form I use captures the drawing number, the shop order, purpose of change, description of markup and who needs to make the change. I'd like to add a button so that I can send an email to the person responsible for the drawing and I want to include the drawing number, shop order, purpose of change and description in the body of the email.

For the responsible person, the list of individuals comes from a separate table where the person's name is in one column and their internal ID is in the second column. I'd like to have the email automatically select the person's internal ID from the table and to put that as the TO: portion of the email.

Unfortunately, I have no idea how to even start to create the code to send the email. Can someone help?
Dec 7 '07 #1
9 3538
BradHodge
166 Expert 100+
I have a database that is tracking drawing markups from our manufacturing shop. The form I use captures the drawing number, the shop order, purpose of change, description of markup and who needs to make the change. I'd like to add a button so that I can send an email to the person responsible for the drawing and I want to include the drawing number, shop order, purpose of change and description in the body of the email.

For the responsible person, the list of individuals comes from a separate table where the person's name is in one column and their internal ID is in the second column. I'd like to have the email automatically select the person's internal ID from the table and to put that as the TO: portion of the email.

Unfortunately, I have no idea how to even start to create the code to send the email. Can someone help?
You might try these two links and see if this gets you started. Link 1 Link 2

Hope that helps,
Brad.
Dec 8 '07 #2
Brad,

Thanks for the links. The second one was very helpful. I do have a few questions about customizing it though.

First - when I use the code pretty much as-is, I get a message window from Outlook saying that a program is tyring to access email addresses stored in Outlook. I have to click Yes three times in order for the box to disappear and for the message to open. Is there any way to eliminate the warning?

Second - When I use the code as-is for adding a recipient and the CC recipient, the CC recipient overwrites the To recipient.
Expand|Select|Wrap|Line Numbers
  1. Set ToContact = .Recipients.Add ("Me@Gmail.com")
  2. ToContact.Type=olCC
  3. Set ToContact = .Recipients.Add("You@Gmail.com")
Third - How do I specify certain fields from the form to be used for the email addresses and for the body of the email?

Thanks,
Sarah
Dec 10 '07 #3
I've been able to add a single field from my form to the body of my email using the following code:

Expand|Select|Wrap|Line Numbers
  1. .body  = "Purpose of Change:  " & Me.purpose_change & vbNewLine 
However, I also want to display the markup ID and the markup description as separate paragraphs. I've tried the following:

Expand|Select|Wrap|Line Numbers
  1. .body = "Purpose of Change:  " & Me.purpose_change & vbNewLine 
  2. & vbNewline & "Markup Description:  " & Me.markup_description
The code fails at the "&" before "Markup Description: ". Any ideas on how to get the different fields to show as separate paragraphs in the body of the email?

Ultimately, for the To: field on the email, I'd like to pull recipients from three potential fields (Engr_resp, Design_resp, DCI_resp) and to ignore any Null entries, but I haven't been able to get it to work either.
Dec 10 '07 #4
BradHodge
166 Expert 100+
I've been able to add a single field from my form to the body of my email using the following code:

Expand|Select|Wrap|Line Numbers
  1. .body  = "Purpose of Change:  " & Me.purpose_change & vbNewLine 
However, I also want to display the markup ID and the markup description as separate paragraphs. I've tried the following:

Expand|Select|Wrap|Line Numbers
  1. .body = "Purpose of Change:  " & Me.purpose_change & vbNewLine 
  2. & vbNewline & "Markup Description:  " & Me.markup_description
The code fails at the "&" before "Markup Description: ". Any ideas on how to get the different fields to show as separate paragraphs in the body of the email?

Ultimately, for the To: field on the email, I'd like to pull recipients from three potential fields (Engr_resp, Design_resp, DCI_resp) and to ignore any Null entries, but I haven't been able to get it to work either.
Sarah,

Unfortunately I don't have Outlook set up on my work PC. I'll take a look at this more when I get home.

Brad.
Dec 10 '07 #5
BradHodge
166 Expert 100+
I've been able to add a single field from my form to the body of my email using the following code:

Expand|Select|Wrap|Line Numbers
  1. .body  = "Purpose of Change:  " & Me.purpose_change & vbNewLine 
However, I also want to display the markup ID and the markup description as separate paragraphs. I've tried the following:

Expand|Select|Wrap|Line Numbers
  1. .body = "Purpose of Change:  " & Me.purpose_change & vbNewLine 
  2. & vbNewline & "Markup Description:  " & Me.markup_description
The code fails at the "&" before "Markup Description: ". Any ideas on how to get the different fields to show as separate paragraphs in the body of the email?

Ultimately, for the To: field on the email, I'd like to pull recipients from three potential fields (Engr_resp, Design_resp, DCI_resp) and to ignore any Null entries, but I haven't been able to get it to work either.
Sarah,

Here's what I've found so far.
Expand|Select|Wrap|Line Numbers
  1. .body = "Purpose of Change:  " & Me.purpose_change & vbNewLine 
  2. & vbNewline & "Markup Description:  " & Me.markup_description
You just need a minor change for this...
Expand|Select|Wrap|Line Numbers
  1.  .body= "Purpose of Change: " & Me.purpose_change & vbNewLine & _
  2. "Markup Description: " & Me.markup_description
In other words, use your vbNewLine followed by "& _" and then go to next line with your next field.

As far as the security messages that Outlook makes you say yes to, there are several downloads that you can get that will stop that. I downloaded one called ClickYes Express that sits in your system tray and you can turn it off or on. Apparently ClickYes Pro allows you to set options, and would likely be a little bit more secure while still allowing you to stop the warnings in this situation.

The CC overwriting the To can be solved by putting the ToContact.Type=olCC line after your CC address.

Hope this helps!

Brad.
Dec 11 '07 #6
Brad,

I was able to get the body section working properly with the extra & _. However I still can't seem to get the addresses to work properly. Here is the code I have:
Expand|Select|Wrap|Line Numbers
  1. Set ToContact = .Recipients.Add(Me.DCI_resp)
  2. Set ToContact = .Recipients.Add(Me.engr_resp)
  3. ToContact.Type = olCC
It pulls in the first address just fine (and I've tried using the three different fields that I want to use - DCI_resp, engr_resp, and design_resp) and they all pull in fine. Unfortunately, the CC field doesn't fill-in now. It doesn't give me any errors (unless the field is blank), but it just doesn't fill-in the CC field.

Any suggestions on how to get it to work? Also, is there a way to get all the fields to go into the TO: box on the email?

Right now, the code crashes if there isn't an entry into one of the fields for the addresses, is there a way to handle blank entries so that the code just skips it?

Thanks,
Sarah
Dec 11 '07 #7
MMcCarthy
14,534 Expert Mod 8TB
Try changing the code to this ...

Expand|Select|Wrap|Line Numbers
  1. Set ToContact = .Recipients.Add(Me.DCI_resp)
  2. ToContact.Type = olTo
  3. Set ToContact = Nothing
  4.  
  5. Set ToContact = .Recipients.Add(Me.engr_resp)
  6. ToContact.Type = olCC
  7. Set ToContact = Nothing
  8.  
You have to reset ToContact to nothing each time or it can cause problems
Dec 12 '07 #8
BradHodge
166 Expert 100+
Try changing the code to this ...

Expand|Select|Wrap|Line Numbers
  1. Set ToContact = .Recipients.Add(Me.DCI_resp)
  2. ToContact.Type = olTo
  3. Set ToContact = Nothing
  4.  
  5. Set ToContact = .Recipients.Add(Me.engr_resp)
  6. ToContact.Type = olCC
  7. Set ToContact = Nothing
  8.  
You have to reset ToContact to nothing each time or it can cause problems
Thanks Mary for the help. Hope all works well for you Sarah!

Brad.
Dec 12 '07 #9
JustJim
407 Expert 256MB
I won't commit the sin of cross-posting, but Adezii and I were just discussing a slightly different aspect of e-mail and outlook over on this thread, and I was wondering anyone on this one had any ideas.

Ho Ho Ho

Jim
Dec 12 '07 #10

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

Similar topics

15
by: Sven Templin | last post by:
Hello all, our configuration is as following described: - OS: Windows 2000 - Apache server 1.3 - Php 3.8 - MS outlook client 2000 _and_ no SMTP server available in the whole intranet.
1
by: Pablo | last post by:
Hi, there, I have a table which has a field (Email) populated with Email address. I am trying to send email using MS Outlook to those addresses. Everything works fine except that a warning message...
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...
8
by: WindAndWaves | last post by:
Hi Gurus I am trying to send a newsletter from Access. Can anyone tell me what is the simplest way to send an email from Access? I would prefer not to use outlook, because this gives me all...
1
by: melsink | last post by:
I am trying find the best method to send email from my a contact access database. I would need to send group emails and save the transaction in access (is. time/date, subject of email and who the...
17
by: Bonj | last post by:
Right guys. (I would like a solution to this in VB6 as this is what our needy app is written in, but any solutions that involve .NET would be much appreciated likewise as I could instantiate...
9
by: B-Dog | last post by:
I've built a small app that sends mail through our ISP's SMTP server but when I try to send through my local exchange server I get CDO error. Does webmail use SMTP or does it strictly rely on...
5
by: horsetransport | last post by:
Hello, Below is what I "Know how to do" but it doesn't accomplish what I want I have table called sndmail fields that matter useremail and mailsent
5
by: J-P-W | last post by:
I have some code, from this group (many thanks) that sends an attachment to an email. The following: Dim objNewMail As Outlook.MailItem Dim golApp As...
5
by: handokowidjaja | last post by:
Hi All, I'm trying to automate sending an email with an attachment in our environment (access 97) using Outlook Express ( we dont have MS outlook or other fancy stuff). Does anybody knows how to...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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
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...

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.