By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,846 Members | 1,680 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,846 IT Pros & Developers. It's quick & easy.

Adding Autosignature when sending email from Access 2003

P: 1
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
Share this Question
Share on Google+
1 Reply


MMcCarthy
Expert Mod 10K+
P: 14,534
This question is being moved to the Access forum.

ADMIN
Apr 2 '07 #2

Post your reply

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