UtterAccess.com
X   Site Message
(Message will auto close in 2 seconds)

Welcome to UtterAccess! Please ( Login   or   Register )

Custom Search
 
   Reply to this topicStart new topic
> Email Template Includes The Signature, Access 2016    
 
   
whitechair
post Aug 19 2019, 01:14 PM
Post#1



Posts: 493
Joined: 26-June 08



I have some code that finds an email template and displays it. The email template has a signature in it and varies according to certain criteria. Therefore, I don't want my default email signature to be included in the email, otherwise there are 2 signatures.

How do I display the email without adding the signature?
CODE
Private Sub cmdSendEmail_Click()
On Error GoTo ErrorCoding

Dim oAccount As Outlook.Account '*****this is here to see if I can send from another account*****
Dim objOutlook As Outlook.Application
Dim objOutlookMsg As Outlook.MailItem
Dim vFirstName As String
Dim vEmailAddress As String
Dim vAgentEmailAddress As String
Dim vStringFind As String
Dim vStringNew As String
Dim vUserName As String
    vUserName = Environ("USERNAME")
Dim vAgentUserName As String
Dim vDOT As Long

Dim vFileName1 As String
Dim vFileName2 As String
Dim vFileName3 As String
Dim vFileName4 As String

'to find DOT Number
    If IsNull(Me!lstCompanyName.Column(6)) Then
        MsgBox "There is no DOT number listed for this client."
        GoTo HandleExit
    ElseIf Me!lstCompanyName.Column(6) = "" Then
        MsgBox "There is no DOT number listed for this client."
        GoTo HandleExit
    Else
        vDOT = Me!lstCompanyName.Column(6)
    End If

'to find contact first name
    If IsNull(Me!lstCompanyName.Column(2)) Then
        MsgBox "There is no contact name listed for this client."
        GoTo HandleExit
    ElseIf Me!lstCompanyName.Column(2) = "" Then
        MsgBox "There is no contact name listed for this client."
        GoTo HandleExit
    Else
        vFirstName = Me!lstCompanyName.Column(2)
    End If
    
'to find email address
    If IsNull(Me!lstCompanyName.Column(8)) Then
        MsgBox "There is no email listed for this client."
        GoTo HandleExit
    ElseIf Me!lstCompanyName.Column(8) = "" Then
        MsgBox "There is no email listed for this client."
    Else
        vEmailAddress = Me!lstCompanyName.Column(8)
    End If

'to assigne agent's email to variable
vAgentEmailAddress = Me!txtAgentEmail

'to assigne agent's user name to variable
vAgentUserName = Me!txtAgentUserName

Application.Echo False

'to output rptPreviousMonthViolations report to PDF on Desktop
    vFileName1 = "C:\users\" & vUserName & "\Desktop\Previous Months Violations.pdf"
DoCmd.OpenReport "rptPreviousMonthViolations", acViewPreview, , "[DOT] =" & vDOT
DoCmd.OutputTo acReport, "rptPreviousMonthViolations", acFormatPDF, vFileName1, False
DoCmd.Close acReport, "rptPreviousMonthViolations"



Dim strSQL As String
strSQL = "SELECT TOP 5 qryHighOffenders1.CompanyName, qryHighOffenders1.DOT, qryHighOffenders1.VIN, Sum(qryHighOffenders1.Total_Points) AS SumOfTotal_Points " & _
"From qryHighOffenders1 " & _
"GROUP BY qryHighOffenders1.CompanyName, qryHighOffenders1.DOT, qryHighOffenders1.VIN " & _
"HAVING (((qryHighOffenders1.DOT) = " & vDOT & ") And ((Sum(qryHighOffenders1.Total_Points)) Is Not Null)) " & _
"ORDER BY Sum(qryHighOffenders1.Total_Points) DESC;"

'MsgBox strSQL

CurrentDb.QueryDefs("qryHighOffenders2").SQL = strSQL


'to output rptHighContributors report to PDF on Desktop
    vFileName2 = "C:\users\" & vUserName & "\Desktop\VIN Detail.pdf"
DoCmd.OpenReport "rptHighContributors", acViewPreview, , "[DOT] =" & vDOT 'add page 1 through 5
DoCmd.OutputTo acReport, "rptHighContributors", acFormatPDF, vFileName2, False
DoCmd.Close acReport, "rptHighContributors"

'to output rptInspectionsFallingOff report to PDF on Desktop
    vFileName3 = "C:\users\" & vUserName & "\Desktop\Upcoming Inspection Removal.pdf"
DoCmd.OpenReport "rptInspectionsFallingOff", acViewPreview, , "[DOT] =" & vDOT
DoCmd.OutputTo acReport, "rptInspectionsFallingOff", acFormatPDF, vFileName3, False
DoCmd.Close acReport, "rptInspectionsFallingOff"

'to output rptInspectionAnalysisReport report to PDF on Desktop
    vFileName4 = "C:\users\" & vUserName & "\Desktop\Inspection Analysis Report.pdf"
DoCmd.OpenReport "rptInspectionAnalysisReport", acViewPreview, , "[DOT] =" & vDOT
DoCmd.OutputTo acReport, "rptInspectionAnalysisReport", acFormatPDF, vFileName4, False
DoCmd.Close acReport, "rptInspectionAnalysisReport"

Application.Echo True

'Create the Outlook session.
Set objOutlook = CreateObject("Outlook.Application")
Set objOutlookMsg = objOutlook.CreateItem(olMailItem)
With Outlook.Application
    'Create the message.
    Set objOutlookMsg = CreateItemFromTemplate("C:\outlooktemplates\InUse\" & vAgentUserName & " Inspection Analysis Tool.oft")
    objOutlookMsg.To = vEmailAddress
    objOutlookMsg.CC = vAgentEmailAddress
    vStringFind = "ClientName"
    vStringNew = vFirstName
    objOutlookMsg.BodyFormat = olFormatHTML
    objOutlookMsg.SentOnBehalfOfName = "akennedy@gmail.com"
    objOutlookMsg.HTMLBody = Replace(objOutlookMsg.HTMLBody, vStringFind, vStringNew)
    objOutlookMsg.Attachments.Add vFileName1
    objOutlookMsg.Attachments.Add vFileName2
    objOutlookMsg.Attachments.Add vFileName3
    objOutlookMsg.Attachments.Add vFileName4
    objOutlookMsg.Display
End With

    DoCmd.SetWarnings False
    Dim vSQL As String
    vSQL = "UPDATE Company SET [LastEmailSent] = #" & Date & "# WHERE DOT = " & vDOT & ";"
    DoCmd.RunSQL vSQL
    DoCmd.SetWarnings True

Call CheckForMCS150Reminder

[Forms]![frmImportInspections]![lstAgentName].Requery
[Forms]![frmImportInspections]![lstCompanyName].Requery

Set objOutlookMsg = Nothing
Set objOutlook = Nothing

HandleExit:
    Exit Sub
ErrorCoding:
    DoCmd.SetWarnings True
    Application.Echo True
    MsgBox Err.Description
    Exit Sub
End Sub

--------------------
Jeff Moseler
Access 2007
Go to the top of the page
 
theDBguy
post Aug 19 2019, 01:17 PM
Post#2


Access Wiki and Forums Moderator
Posts: 76,315
Joined: 19-June 07
From: SunnySandyEggo


Hi Jeff. I haven't looked at your code, but are you doing anything specific in it to add the signatures? If not, then have you considered creating a template without a signature? Or, create two separate templates based on what signature you need, and then use the correct template? Just a thought...

--------------------
Just my 2 cents... "And if I claim to be a wise man, it surely means that I don't know" - Kansas
Access Website | Access Blog | Email
Go to the top of the page
 
whitechair
post Aug 19 2019, 01:40 PM
Post#3



Posts: 493
Joined: 26-June 08



Right now I'm using the second option. I have a total of 6 templates depending on who I am sending the email to.

The template has a signature in it. But then it adds my default signature at the bottom so there are 2 signatures. Is there a way to prevent the default signature?

--------------------
Jeff Moseler
Access 2007
Go to the top of the page
 
theDBguy
post Aug 19 2019, 01:49 PM
Post#4


Access Wiki and Forums Moderator
Posts: 76,315
Joined: 19-June 07
From: SunnySandyEggo


Hi Jeff. That's a very interesting question. Everything I have run into before were about questions on how to "add" the default signature instead of removing it. This was because typically, the default signature doesn't show up and forces us to find a way to add it. It's interesting you're having the opposite experience. I am wondering if MS/Outlook finally changed its behavior to automatically add the default signature now. In other words, I don't have any idea as for right now. I'll let you know if I figure anything out.

--------------------
Just my 2 cents... "And if I claim to be a wise man, it surely means that I don't know" - Kansas
Access Website | Access Blog | Email
Go to the top of the page
 
ADezii
post Aug 19 2019, 02:00 PM
Post#5



Posts: 2,635
Joined: 4-February 07
From: USA, Florida, Delray Beach


  1. I am not 100% sure of this, so please take some things that I post here with a grain of salt. Let's assume that your Default Signature is named Default. The actual Signature File(s) can exist in any of three possible Formats, namely: Default.txt, Default.rtf, or Default.htm. The Path containing these Signature Files is
    CODE
    Environ("AppData") & "\Microsoft\Signatures\"
  2. I am assuming that if you Move or Delete the Default Signature Files, then there will be no Default Signature to display, as in:
    CODE
    Kill Environ("AppData") & "\Microsoft\Signatures\Default.*"
  3. UPDATE: I just moved my Default Signature to another Folder and it did not appear on a New E-Mail.

This post has been edited by ADezii: Aug 19 2019, 02:04 PM
Go to the top of the page
 


Custom Search


RSSSearch   Top   Lo-Fi    19th September 2019 - 04:22 PM