Solved

How to get subject to merge automatically into email

Posted on 2014-02-06
13
402 Views
Last Modified: 2014-02-19
How do I get the subject to merge into this access database.  See the attached database.  SOmeone was helping me get it all set up,  but the one thing that is missing in the code is auto filling in the subject from the tblbodytemplate table.  I think I need to add a subject column in the table.  

It works by click the send email button which merges into my default email program.
1.accdb
0
Comment
Question by:lehi52
  • 7
  • 6
13 Comments
 
LVL 10

Expert Comment

by:Gozreh
ID: 39839755
Yes, you should add new field "Subject", then you will need to add in the subject  
DLookup("Subject", "tblBodyTemplate", "TemplateID=" & Form_frmSelectTemplate.TemplateID)

Open in new window

0
 

Author Comment

by:lehi52
ID: 39839777
I added subject and included Body text and it pulled an error. I need it to pul both the subject and the body text into that email.  
DLookup("Subject", "BodyText", "tblBodyTemplate", "TemplateID=" & Form_frmSelectTemplate.TemplateID)

Open in new window

0
 
LVL 10

Accepted Solution

by:
Gozreh earned 500 total points
ID: 39839794
No, Dlookup can only retrieve one expr at ones
this the Dlookup syntax  DLookup(expr, domain [, criteria] )
you can read here http://office.microsoft.com/en-us/access-help/dlookup-function-HA001228825.aspx
0
 

Author Comment

by:lehi52
ID: 39839799
That is good to know.  I will probably ask another question then on how to automatically pull the subject with the body text.
0
 
LVL 10

Expert Comment

by:Gozreh
ID: 39839802
Your code here should be
   Dim strBody As String, strBodyText As String
   Dim strSubject As String
   strBody = "Dear " & Me.Connam_Name & vbCrLf & vbCrLf & "Here you will find the attached report......"
   
   DoCmd.OpenForm "frmSelectTemplate", , , , , acDialog
   strBodyText = DLookup("BodyText", "tblBodyTemplate", "TemplateID=" & Form_frmSelectTemplate.TemplateID)
   strSubject = DLookup("Subject", "tblBodyTemplate", "TemplateID=" & Form_frmSelectTemplate.TemplateID)
   DoCmd.Close acForm, "frmSelectTemplate"
   strBody = strBody & ConvertBody(strBodyText)
   
   DoCmd.SendObject acReport, "actions and opps", "PDFFormat(*.pdf)", Me.[Connam Email], , , strSubject, strBody

Open in new window

0
 

Author Comment

by:lehi52
ID: 39839846
This code did not pull in the subject.
0
Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

 
LVL 10

Expert Comment

by:Gozreh
ID: 39839865
did you remove the report "actions and opps" or renamed it ?
0
 

Author Comment

by:lehi52
ID: 39839866
I renamed it.  to Action to do. But what if I wanted another option to also remove the attachment.
0
 
LVL 10

Expert Comment

by:Gozreh
ID: 39839885
Like Scott McDaniel answered you in previous question http://www.experts-exchange.com/Microsoft/Development/MS_Access/Q_28357659.html
that if you want to attach other pdf's and not from your reports, then you should use the outlook object instate of using the sentopject.
0
 

Author Comment

by:lehi52
ID: 39839887
Gozreh,   I mean to just not include an attachment at all.  Sorry I wasnt clear on that.
0
 

Author Comment

by:lehi52
ID: 39839895
I tried to remove that line of code and the button click didn't work so I wasnt sure what I was doing wrong.

I guess this is another question which I can ask elsewhere if you prefer. Mainly here I would like to get the subject line inserting.
0
 
LVL 10

Expert Comment

by:Gozreh
ID: 39839931
to send the report "Actions To Do" you can use this:
   DoCmd.SendObject acReport, "Actions To Do", acFormatPDF, Me.[Connam Email], , , strSubject, strBody

if you need to send email without report attached you should use this:
   DoCmd.SendObject acSendNoObject, , , Me.[Connam Email], , , strSubject, strBody

please check all option you can do with the SendObject method http://msdn.microsoft.com/en-us/library/office/ff197046.aspx

you can also see their on bottom of the page how to send email using outlook objects
0
 

Author Comment

by:lehi52
ID: 39839971
The subject line does merge now.  Gorzeh thank you.
0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

This article is a continuation or rather an extension from Cascading Combos (http://www.experts-exchange.com/A_5949.html) and builds on examples developed in detail there. It should be understandable alone, but I recommend reading the previous artic…
The first two articles in this short series — Using a Criteria Form to Filter Records (http://www.experts-exchange.com/A_6069.html) and Building a Custom Filter (http://www.experts-exchange.com/A_6070.html) — discuss in some detail how a form can be…
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…

758 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now