473,386 Members | 1,699 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Adding outlook signature to email through access

56
I'm have automated the creation of an email from Access; whic works
fine,
but the new email doesn't have the user's default signature on it. Is
there any way to either have it find the user's default signature and
add it to the bottom of the email.

Here is my code for sending the emails:

Expand|Select|Wrap|Line Numbers
  1. Function SendEmail()
  2. Dim rst As DAO.Recordset
  3.     Dim strSQL As String
  4.     Dim olApp As Outlook.Application
  5.     Dim objMail As Outlook.MailItem
  6.     Dim strMessage As String
  7.  
  8.     Dim strTableBeg As String
  9.     Dim strTableEnd As String
  10.     Dim strFntNormal As String
  11.     Dim strFntHeader As String
  12.     Dim strFntEnd As String
  13.  
  14.     ' Define format for output ------------------------------------------------
  15.     strTableBeg = "<table border=0>"
  16.     strTableEnd = "</table>"
  17.     strFntHeader = "<font size=2 face=" & Chr(34) & "Arial" & Chr(34) & "><b>" & _
  18.                         "<tr bgcolor=lightblue>" & _
  19.                             "<td nowrap>Insured</td>" & _
  20.                             "<td>Policy</td>" & _
  21.                             "<td>SP Policy</td>" & _
  22.                             "<td>Trans Type</td>" & _
  23.                             "<td>Eff. Date</td>" & _
  24.                             "<td align=center>Gross</td>" & _
  25.                             "<td align=center>Commission</td>" & _
  26.                             "<td align=center>Net</td>" & _
  27.                         "</tr></b></font>"
  28.     strFntNormal = "<font color=black face=" & Chr(34) & "Arial" & Chr(34) & " size=1>"
  29.     strFntEnd = "</font>"
  30.  
  31.     ' HEADER LINES -----------------------------------------------------------
  32.     strMessage = strTableBeg & strFntNormal & strFntHeader
  33.  
  34.     ' DETAIL LINES -----------------------------------------------------------
  35.     strSQL = "SELECT InsName,Policy,SpcPol,TranType,BillEffdte,Gross,Comm " & _
  36.              "FROM TARA " & _
  37.              "WHERE check = True and TARA.Email = fOSUserName()"
  38.     Set rst = CurrentDb.OpenRecordset(strSQL)
  39.  
  40.     Do Until rst.EOF
  41.         strMessage = strMessage & _
  42.                         "<tr>" & _
  43.                             "<td>" & rst!InsName & "</td>" & _
  44.                             "<td>" & rst!Policy & "</td>" & _
  45.                             "<td>" & rst!SpcPol & "</td>" & _
  46.                             "<td>" & rst!TranType & "</td>" & _
  47.                             "<td>" & rst!BillEffDte & "</td>" & _
  48.                             "<td align=right>" & Format(rst!Gross, "currency") & "</td>" & _
  49.                             "<td align=right>" & Format(rst!Comm, "currency") & "</td>" & _
  50.                             "<td align=right>" & Format(rst!Gross - rst!Comm, "currency") & "</td>" & _
  51.                         "</tr>"
  52.         rst.MoveNext
  53.     Loop
  54.  
  55.     rst.Close
  56.     Set rst = Nothing
  57.  
  58.     ' TOTALS LINE -------------------------------------------------------------
  59.     strSQL = "SELECT Sum(TARA.Gross) AS SumOfGross, " & _
  60.                     "Sum(TARA.Comm) AS SumOfComm " & _
  61.             "FROM TARA " & _
  62.             "WHERE (((TARA.check)=True AND TARA.Email = fOSUserName()))"
  63.             Debug.Print strSQL
  64.     Set rst = CurrentDb.OpenRecordset(strSQL)
  65.     strMessage = strMessage & "<font size=2><b>" & _
  66.                     "<tr>" & _
  67.                         "<td>" & " " & "</td>" & _
  68.                         "<td>" & " " & "</td>" & _
  69.                         "<td>" & " " & "</td>" & _
  70.                         "<td>" & " " & "</td>" & _
  71.                         "<td>Total</td>" & _
  72.                         "<td align=right>" & Format(rst!SumOfGross, "currency") & "</td>" & _
  73.                         "<td align=right>" & Format(rst!SumOfComm, "currency") & "</td>" & _
  74.                         "<td align=right>" & Format(rst!SumOfGross - rst!SumOfComm, "currency") & "</td>" & _
  75.                     "</tr>"
  76.     rst.Close
  77.     Set rst = Nothing
  78.  
  79.     ' CLOSE THE TABLE ---------------------------------------------------------
  80.     strMessage = strMessage & strFntEnd & strTableEnd
  81.  
  82.     ' Create e-mail item ------------------------------------------------------
  83.     Set olApp = Outlook.Application
  84.     Set objMail = olApp.CreateItem(olMailItem)
  85.     With objMail
  86.         'Set body format to HTML
  87.         .To = " "
  88.         .Subject = "Past Due Item"
  89.         .BodyFormat = olFormatHTML
  90.         .HTMLBody = "<HTML><BODY>" & strFntNormal & strMessage & " </BODY></HTML>"
  91.         .Display
  92.     End With
  93. End Function
Jul 3 '07 #1
1 4366
MMcCarthy
14,534 Expert Mod 8TB
Firstly, when using code tags put a backslash before the word code in the closing tag.

I'm not that familiar with Outlook automation but my understanding of outlook is that the signature is tied to the account sending the email. It sounds like your code is not picking up the correct account.
Jul 7 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: VP | last post by:
g'day, i am posting a problem i have encountered with creating an email using outlook through some basic c# code. the problem arises when using different email editors in outlook. At the moment...
62
by: Ecohouse | last post by:
I was just wondering if there was any way to use a toolbar in Outlook 2002 in Access 2002? I want to create a custom toolbar in Access similar to the Calendar toolbar in Outlook. Any ideas?
3
by: Jeff | last post by:
I am trying to send emails from my application (not using a plugin, that will come later), I can create an email and add attachments. I can fill in the body etc. Word works for the editor. So...
0
by: Slug | last post by:
Hello there, I am trying to create an add-in for Outlook using the VS.Net 2005 Shared Add-In project type. I've progressed far enough to have added a button to the main toolbar and have it...
5
by: Kosmos | last post by:
I have traveled the world and the seven seas and I have yet to come up with an answer to this question.... So I'm adding an attachment to an email from access... The following is the code: ...
2
by: Kosmos | last post by:
Alright so I've got this Outlook code written in VBA in Access. The first part, which works, records information about appointment times based on the required days before notification of certain...
0
by: RLN | last post by:
Hello. Re: Access 2003 / Outlook 2003 I would like to do some bulk modifications to the following fields on these default forms in Outlook for a specific .pst file in...
1
by: yevgenia | last post by:
Hi there, I am developing an application in Access 2003 and need to send an email through Outlook based on the information entered on the form. Everything works except that the email is being sent...
7
by: clloyd | last post by:
I have VBA code that creates an email that complete the TO: CC: Subject and Body Text however, it does not put the signature on the email. Is there an easy way to tell the code to use the default...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
Oralloy
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,...
0
jinu1996
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 using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.