Solved

How to get subject to merge automatically into email

Posted on 2014-02-06
13
403 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
Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Introduction The Visual Basic for Applications (VBA) language is at the heart of every application that you write. It is your key to taking Access beyond the world of wizards into a world where anything is possible. This article introduces you to…
Overview: This article:       (a) explains one principle method to cross-reference invoice items in Quickbooks®       (b) explores the reasons one might need to cross-reference invoice items       (c) provides a sample process for creating a M…
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …

930 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

9 Experts available now in Live!

Get 1:1 Help Now