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?
9 3538
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.
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. - Set ToContact = .Recipients.Add ("Me@Gmail.com")
-
ToContact.Type=olCC
-
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
I've been able to add a single field from my form to the body of my email using the following code: - .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: - .body = "Purpose of Change: " & Me.purpose_change & vbNewLine
-
& 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.
I've been able to add a single field from my form to the body of my email using the following code: - .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: - .body = "Purpose of Change: " & Me.purpose_change & vbNewLine
-
& 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.
I've been able to add a single field from my form to the body of my email using the following code: - .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: - .body = "Purpose of Change: " & Me.purpose_change & vbNewLine
-
& 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. - .body = "Purpose of Change: " & Me.purpose_change & vbNewLine
-
& vbNewline & "Markup Description: " & Me.markup_description
You just need a minor change for this... - .body= "Purpose of Change: " & Me.purpose_change & vbNewLine & _
-
"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.
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: - Set ToContact = .Recipients.Add(Me.DCI_resp)
-
Set ToContact = .Recipients.Add(Me.engr_resp)
-
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
Try changing the code to this ... -
Set ToContact = .Recipients.Add(Me.DCI_resp)
-
ToContact.Type = olTo
-
Set ToContact = Nothing
-
-
Set ToContact = .Recipients.Add(Me.engr_resp)
-
ToContact.Type = olCC
-
Set ToContact = Nothing
-
You have to reset ToContact to nothing each time or it can cause problems
Try changing the code to this ... -
Set ToContact = .Recipients.Add(Me.DCI_resp)
-
ToContact.Type = olTo
-
Set ToContact = Nothing
-
-
Set ToContact = .Recipients.Add(Me.engr_resp)
-
ToContact.Type = olCC
-
Set ToContact = Nothing
-
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.
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
Sign in to post your reply or Sign up for a free account.
Similar topics
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.
|
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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
|
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...
|
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...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
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...
|
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...
|
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...
|
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,...
|
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...
|
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...
|
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,...
|
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...
| |