Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

How to get subject to merge automatically into email

Posted on 2014-02-06
13
Medium Priority
?
417 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 2000 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
Prepare for your VMware VCP6-DCV exam.

Josh Coen and Jason Langer have prepared the latest edition of VCP study guide. Both authors have been working in the IT field for more than a decade, and both hold VMware certifications. This 163-page guide covers all 10 of the exam blueprint sections.

 

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
 
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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

We live in a world of interfaces like the one in the title picture. VBA also allows to use interfaces which offers a lot of possibilities. This article describes how to use interfaces in VBA and how to work around their bugs.
Windows Explorer lets you open cabinet (cab) files like any other folder. In VBA you can easily handle normal files and folders, but opening and indeed creating cabinet files takes a lot more - and that's you'll find here.
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…
Suggested Courses

886 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