473,756 Members | 6,970 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Adding outlook signature to email through access

56 New Member
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 4414
MMcCarthy
14,534 Recognized Expert Moderator MVP
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
2148
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 i am using outlook 2000. Outlook can be configured to use the default outlook email editor or use ms word as the email editor in outlook. The sample code below simply creates an email with a hyperlink. The problem I am facing is that when...
62
11417
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
10650
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 mostly what I want. My issue is I would like to retain the signature block that exists when I insert my body into the message. Any help would be appreciated. Here is the code I am using: //Initialize the envelope values. string strTo =...
0
1095
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 display a messagebox when clicked. Can anybody explain to me how I can achieve the following:
5
5363
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: and from here I go to the end (because the other part is in an If statement and that's in a loop...once the loop's finished, I've gathered the necessary information I would paste the full function but I already have in another place on this site and...
2
3672
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 contracts and then it adds them to the outlook calendar of the current user. This code works and is nested within a bunch of if statements because it only needs to trap certain appointments. The table I create with this code is later used to attempt to...
0
1288
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 C:\MyFolder\MyOutlookStuff.pst : -Remove parentheses on the phone numbers in the "Home Phone", Business Phone" and "Mobile Phone" fields on the "General" form tab. -Modify "Category" & "Notes" on the "General" form tab -Modify "Profession" on the "Details" form tab
1
2599
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 as plain text so none of the formatting is retained. Also, I can't figure out how to get Outlook to pick up the autosignature. The script I'm using is: Private Sub cmdSendEmail_Click() On Error GoTo StartError Dim stLinkCriteria As String...
7
8251
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 signature that you get if you create, reply or forward an email?
0
9297
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9904
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9884
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8736
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7285
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5324
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3828
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3395
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2697
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.