Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Emailing from within Access doesn't pick up Outlook Signature

Status
Not open for further replies.
Sep 18, 2006
71
US
Client: Windows XP Pro, fully updated
Software: Office 2000, fully updated

Our Outlook 2000 clients are set up w/ a signature attached to each & every outgoing email. It works perfectly UNTIL we try to email from within Access.

Our billing system is in Access 2000. The user generates an invoice, clicks on the email icon with the little paperclip & an email pops up with the invoice attached. The email itself always opens in the upper left corner of the desktop - real small, like 3"x3". Once expanded the signature is mia. She can go to Insert, Signature, (Name) which will insert the signature but why isn't already there when the email is generated?!

Also, the email generated via this method is always in Plain Text. Odd, b/c her Outlook is config'd to create emails in Rich Text. To test, I converted my email over to only generate Plain Text emails. The few I created all had the correct signature added so the format of new emails as configured within Outlook seems to be irrelevant to Access using it!

And, even more odd, I tried saving one of these invoice-generated emails b/c I wanted to see how it looks within Outlook itself. But it doesn't get saved to the Drafts folder - it gets saved to the Inbox!??!!?

It's like Access is using a stripped down / dummy version of Outlook or something....? So I guess my questions are WHY does this happen & is there a way to make it pickup up the signature without manually adding it?
 
By what method are you having Access create the email?
 
bubba100 - I saw your post yesterday & emailed the developer for the answer. Will post as soon as I hear back from her!
 
TRy doing this...

Code:
Function SendOutlookMessage(ByVal Recipients As String, ByVal Subject As String, ByVal Body As String, ByVal DisplayMsg As Boolean, Optional ByVal ReplyTo As String, Optional ByVal CopyRecipients As String, Optional ByVal BlindCopyRecipients As String, Optional ByVal Importance As Integer = 2, Optional ByVal AttachmentPath)
'Function to create and send an outlook message with more control than sendobject
'separate multiple recipients or CC, or BCC with comma
'importance - 1=low, 2=normal, 3=high

Dim objOutlook As Outlook.Application
Dim objOutlookMsg As Outlook.MailItem
Dim objOutlookRecip As Outlook.Recipient
Dim objOutlookReplyTo As Outlook.Recipient
Dim objOutlookAttach As Outlook.Attachment
Dim txtRecipient, txtAttachPath As String
Dim blResolved As Boolean
Dim x As Integer 'multiple use integer for loops

          ' Create the Outlook session.
          Set objOutlook = CreateObject("Outlook.Application")

          ' Create the message.
          Set objOutlookMsg = objOutlook.CreateItem(olMailItem)

          With objOutlookMsg
          .Display
            ' Add the To recipient(s) to the message.
            For x = 1 To (CharCount(Recipients, ",") + 1) 'checks for multiple recipients and adds each
                txtRecipient = ReturnWord(Recipients, x, ",")
                If txtRecipient <> "" Then
                    Set objOutlookRecip = .Recipients.Add(txtRecipient)
                    objOutlookRecip.Type = olTo
                End If
            Next
                
              ' Add the CC recipient(s) to the message if existing
            For x = 1 To (CharCount(CopyRecipients, ",") + 1) 'checks for multiple recipients and adds each
                txtRecipient = ReturnWord(CopyRecipients, x, ",")
                If txtRecipient <> "" Then
                    Set objOutlookRecip = .Recipients.Add(txtRecipient)
                    objOutlookRecip.Type = olCC
                End If
            Next x
            
            ' Add the BCC recipient(s) to the message.
            For x = 1 To (CharCount(BlindCopyRecipients, ",") + 1) 'checks for multiple recipients and adds each
                txtRecipient = ReturnWord(BlindCopyRecipients, x, ",")
                If BlindCopyRecipients <> "" Then
                    Set objOutlookRecip = .Recipients.Add(txtRecipient)
                    objOutlookRecip.Type = olBCC
                End If
            Next x
            
            'set the reply to address
            If ReplyTo <> "" Then
                Set objOutlookReplyTo = .ReplyRecipients.Add(ReplyTo)
            End If
                        
             ' Set the Subject, Body, and Importance of the message.
             .Subject = Subject
             .HTMLBody = "<p>" & Body & "<p>" & .HTMLBody
             Select Case Importance
                Case 1
                   .Importance = olImportanceLow
                Case 2
                    .Importance = olImportanceNormal
                Case 3
                    .Importance = olImportanceHigh
                Case Else
                    .Importance = olImportanceNormal
             End Select
 
             ' Add attachments to the message.
             If Not IsMissing(AttachmentPath) Then
                 For x = 1 To (CharCount(AttachmentPath, ",") + 1)
                    txtAttachPath = ReturnWord(AttachmentPath, x, ",")
                    Set objOutlookAttach = .Attachments.Add(txtAttachPath)
                 Next
             End If

             ' Resolve each Recipient's name.
             For Each objOutlookRecip In .Recipients
                 objOutlookRecip.Resolve
             Next
             
             ' Should we display the message before sending?
             blResolved = True
             For Each objOutlookRecip In .Recipients
                 blResolved = objOutlookRecip.Resolved And blResolved
             Next
                          
             If DisplayMsg Then
                .Display
             Else
                If blResolved = False Then 'at least one name didnt resolve so display
                    .Display
                Else
                    .Save
                    .Send
                End If
             End If
          End With
          Set objOutlook = Nothing
      
End Function

The important part is the .display before any other action. That creates the email, displaying before setting anything else applies the default templte.

Remember, if you are using HTML, you will need to replace CHR$(13) with <BR><BR> ir you get no line breaks.... Also, any text you add goes BELOW anything already in the email, so you may need to grab the current content, add you text and write it back to the email.

SeeThru
Synergy Connections Ltd - Telemarketing Services
 
SeeThru - Wow! Thank you so much! I just forwarded it to the developer & will have her implement asap to see if that does the trick. Will post back as soon as we try it out!
 
NB: This uses a custom function called returnword that split a supplied string into 'words' seprated by a supplied character.

In this case it split 'John Smith, Joe Bloggs, AN Other" - the code loops thruogh this three times, adding each to outlook and resolving it before adding the next.

If you only sent to a singe recipient, add a single attachment, etc, you can simplify this code by replcing a section like

Code:
For x = 1 To (CharCount(Recipients, ",") + 1) 'checks for multiple recipients and adds each
   txtRecipient = ReturnWord(Recipients, x, ",")
   If txtRecipient <> "" Then
     Set objOutlookRecip = .Recipients.Add(txtRecipient)
     objOutlookRecip.Type = olTo
   End If
Next

with a much simpler
Code:
Set objOutlookRecip = "Joe Bloggs"
objOutlookRecip.Type = olTo


SeeThru
Synergy Connections Ltd - Telemarketing Services
 
SeeThru - Thanks AGAIN! I'll forward this update to the developer as well!! I really appreciate your time & like I said, as soon as she implements these fixes I'll let you know what does / doesn't work.
 
SeeThru - Just dropping you a quick line - the developer has been swamped & hasn't had a chance to try your suggestions. I don't want you to think I forgot about getting back to you w/ feedback. I promise I will as soon as she tries your code!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top