473,386 Members | 1,819 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 Autosignature when sending email from Access 2003

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:
Expand|Select|Wrap|Line Numbers
  1. Private Sub cmdSendEmail_Click()
  2.  On Error GoTo StartError
  3.  Dim stLinkCriteria As String
  4.     Dim stSubject As String
  5.     Dim sthtmlBody As String
  6.  
  7.     Dim objItem As Object
  8.     Dim objInsp As Outlook.Inspector
  9.     ' requires a project reference to the
  10.     ' Microsoft Word library
  11.     Dim objDoc As Word.Document
  12.     Dim objSel As Word.Selection
  13.     Dim objCB As Office.CommandBar
  14.     Dim objCBP As Office.CommandBarPopup
  15.     Dim objCBB As Office.CommandBarButton
  16.     Dim colCBControls As Office.CommandBarControls
  17.  
  18. 'insert autosig
  19. Set objInsp = Application.ActiveInspector
  20.     If Not objInsp Is Nothing Then
  21.         Set objItem = objInsp.CurrentItem
  22.         If objItem.Class = olMail Then  ' editor is WordMail
  23.             If objInsp.EditorType = olEditorWord Then
  24.                 ' next statement will trigger security prompt
  25.                 ' in Outlook 2002 SP3
  26.                 Set objDoc = objInsp.WordEditor
  27.                 Set objSel = objDoc.Application.Selection
  28.                 If objDoc.Bookmarks("_MailAutoSig") Is Nothing Then
  29.                     objDoc.Bookmarks.Add Range:=objSel.Range, name:="_MailAutoSig"
  30.                 End If
  31.                 objSel.GoTo What:=wdGoToBookmark, name:="_MailAutoSig"
  32.                 Set objCB = objDoc.CommandBars("AutoSignature Popup")
  33.                 If Not objCB Is Nothing Then
  34.                     Set colCBControls = objCB.Controls
  35.                 End If
  36.            Else ' editor is not WordMail
  37.                 get the Insert | Signature submenu
  38.  
  39.                Set objCBP = Application.ActiveInspector.CommandBars.FindControl(, 31145)
  40.                If Not objCBP Is Nothing Then
  41.                     Set colCBControls = objCBP.Controls
  42.                 End If
  43.             End If
  44.        End If
  45.        If Not colCBControls Is Nothing Then
  46.            For Each objCBB In colCBControls
  47.                If objCBB.Caption = strSigName Then
  48.                    objCBB.Execute ' **** see remarks
  49.                    Exit For
  50.               End If
  51.         End If
  52.  End If
  53.  
  54.     If IsNull([ContactMode]) Or ([ContactMode]) = "" Then
  55.       MsgBox "No email is specified."
  56.     ElseIf IsNull([Purpose]) Or ([Purpose]) = "" Then
  57.         MsgBox "There is no subject line."
  58.     ElseIf IsNull([Action]) Or ([Action]) = "" Then
  59.         MsgBox "The email body is empty."
  60.  
  61.        Exit Sub
  62.  
  63.     Else
  64.        stLinkCriteria = Me![ContactMode]
  65.        stSubject = Me![Purpose]
  66.        sthtmlBody = Me![Action]
  67.        DoCmd.SendObject acSendNoObject, , , stLinkCriteria, , , stSubject, sthtmlBody
  68.  
  69.     End If
  70.  
  71.     Set objInsp = Nothing
  72.     Set objItem = Nothing
  73.     Set objDoc = Nothing
  74.     Set objSel = Nothing
  75.     Set objCB = Nothing
  76.     Set objCBB = Nothing
  77.  
  78. StartError:
  79.     MsgBox "No email was sent."
  80.     Exit Sub
  81. End Sub
Apr 2 '07 #1
1 2584
MMcCarthy
14,534 Expert Mod 8TB
This question is being moved to the Access forum.

ADMIN
Apr 2 '07 #2

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

Similar topics

3
by: Jared | last post by:
Hello people, I've had major difficulties finding the right Java technology that can be used to make an e-mail applet program. I'm trying to build an applet that would be similar, but much...
2
by: Del | last post by:
I have two question on sending email messages from MS Access (Versio 2000, 2002, and 2003). I have a form with a command button to send an email message, the code behide the button is as follows;...
2
by: Tom Dauria | last post by:
I have a Access database application that sends email through Outlook. A few years ago we started having a problem where it would ask for each and every email being sent whether you want to give...
1
by: melsink | last post by:
I am trying find the best method to send email from my a contact access database. I would need to send group emails and save the transaction in access (is. time/date, subject of email and who the...
2
by: acewood1 | last post by:
I've done some searching in the archives but can't seem to find an easy answer as to how to send a Groupwise email through Access 2003. I just need to open a new email and populate the "To:" line...
1
by: Dmitry Davletbaev | last post by:
Hi! I have an ASP page with script in it. This script makes connection to Access database (JET 4.0) and retrieves data. Some time later this page became unavailable with following error: HTTP...
1
by: dkao99 | last post by:
I have problem with the following code when OUTLOOK.EXE process in on. First, I make sure no outlook is running. The "GetObject" will set the oOApp to outlook and the code works fine. One problem is...
2
abdoelmasry
by: abdoelmasry | last post by:
Hi men i have big problem with microsoft exchange server 2003 i installed exchange server as main mail server to use it on in company i have static real ip address im sending and...
6
by: teddysnips | last post by:
I'm having trouble adding Access 2003 databases to Sourcesafe. I go to Tools, Sourcesafe, Add Database to Sourcesafe... at which point a message box appears saying "This database must be closed...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: 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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
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...

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.