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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

HTML e-mail frustrating problem

Status
Not open for further replies.

ErnstJan

Programmer
Nov 10, 2002
114
NL
Hello,

I have created a e-mail solution for a customer.
The e-mail is HTML format.
The program creates the body and add a signatur at the end.
The signature is a HTML file that is added to the body.

All is working fine if Word is not the e-mail editor.
If I turn on Word as E-mail editor then the signature is shown but the rest of the text is gone.
The customer want to use Word as e-mail editor. So simply turning that of is no option

Does anyone have a solution for me

Thanks in advance

Ernst Jan

Code for making e-mail:
Code:
'Gegevens opvragen
        Set tblBron = CurrentDb.OpenRecordset("SELECT * FROM qryOverzichtOpenstaandeCalls WHERE " & varFilter)
        'E-Bericht opbouwen
        '   Aanhef
        varbericht = varbericht & "<body>" & _
                        "<font face='Trebuchet MS' Size=2>" & _
                        "Beste " & IIf(IsNull(Me.keuzeLeverancier.Column(varAanhef)) Or Me.keuzeLeverancier.Column(varAanhef) = "", "heer/mevrouw,", Me.keuzeLeverancier.Column(varAanhef) & ",") & "<Br><br>" & _
                        "Hierbij de openstaande punten per " & Format(Now(), "dd-mmm-yyyy") & ", " & Format(Now(), "hh:mm") & " uur: <br><br>" & varbericht
        
        '   Regels invoegen
        Do Until tblBron.EOF
            varbericht = varbericht & "<b>Onze Ref.&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;: </b>" & tblBron!Call_ID & "<br>"
            varbericht = varbericht & "<b>Uw Ref.&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;: </b>" & tblBron!Referentie & "<br>"
            varbericht = varbericht & "<b>Prioriteit&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;: </b>" & tblBron!Prio & "<br>"
            varbericht = varbericht & "<b>Omschrijving&nbsp;&nbsp;: </b>" & tblBron!KorteOmschrijving & "<br><br>"
            
            'Volgende regel
            tblBron.MoveNext
        Loop
        'gegevens tabel sluiten
        tblBron.Close
  
        'Handtekening toevoegen
        varbericht = EmailBericht(varbericht)
        
        'Controleren of er een email adres beschikbaar is
        If Me.keuzeLeverancier.Column(varEmail) <> "" And Not IsNull(Me.keuzeLeverancier.Column(varEmail)) Then
            'Email adres naar klembord copieeren om beveiliging te omzeilen
            Me.Klembord = Me.keuzeLeverancier.Column(varEmail)
            varLengte = Len(Me.keuzeLeverancier.Column(varEmail))
        Else
            Me.Klembord = " "
            varLengte = Len(" ")
        End If
        
        'Email adres naar klembord kopieeren
        Me.Klembord.SetFocus
        Me.Klembord.SelStart = 0
        Me.Klembord.SelLength = varLengte
        DoCmd.RunCommand acCmdCopy
        Me.btnVersturen.SetFocus
        
        'E-mail aanmaken
        Set Outlook = CreateObject("Outlook.Application")
        Set MyItem = Outlook.CreateItem(olMailItem)
        
        'Set MyAttachments = MyItem.Attachments
        MyItem.Subject = "Openstaande punten " & Format(Now(), "dd-mm-yy")
          
        'Bericht instellen samen met handtekening
        MyItem.HTMLBody = varbericht

        'Bericht venster tonen
        MyItem.Display
        SendKeys "+{INSERT}"

Code for adding signature
Code:
Function EmailBericht(varbericht As String) As String
On Error GoTo EmailBericht_Err
    Const ForReading = 1, ForWriting = 2, ForAppending = 3

    Dim Fs, f
    Dim RTFBody As String

    'File system object aanmaken
    Set Fs = CreateObject("Scripting.FileSystemObject")
    'Controleren of bestand is gevonden
    If Fs.FileExists(CurrentProject.Path & "\Burando Martijn.HTM") = True Then
        'Bestand inlezen
        Set f = Fs.OpenTextFile(CurrentProject.Path & "\Burando Martijn.HTM", ForReading)
        'Handtekening aanmaken
        RTFBody = f.readall
        'Object sluiten
        f.Close
    Else
        MsgBox "Handtekeningen bestand is niet gevonden." & vbCr & _
                "(" & CurrentProject.Path & "\Burando Martijn.htm)", vbExclamation, "Geen handtekening"
    End If

    'Bericht en handtekening samenvoegen
    EmailBericht = varbericht & RTFBody

EmailBericht_Exit:
    Set Fs = Nothing
    Set f = Nothing
    Exit Function
    
EmailBericht_Err:
    MsgBox err.Description, vbCritical, "Probleem met toevoegen Handtekening"
    Resume EmailBericht_Exit
End Function

Sorry for Dutch comment rows
 
Try this:

Code:
 'E-mail aanmaken
 Set Outlook = CreateObject("Outlook.Application")
 Set MyItem = Outlook.CreateItem(olMailItem)
 
 [red]MyItem.GetInspector.iswordmail[/red]

 'Set MyAttachments = MyItem.Attachments
 MyItem.Subject = "Openstaande punten " & Format(Now(), "dd-mm-yy")
   
 'Bericht instellen samen met handtekening
 MyItem.HTMLBody = "varbericht"

 'Bericht venster tonen
 MyItem.Display
 
 SendKeys "+{INSERT}"

It seems to work for me.
 
Hi Remou,

Thanks for the repley, but your solution does not work for me.

Is there away to do the next:
Check if Word is set as email editor.
If so turn it off.
Create e-mail and display.
Turn word on as e-mail editor if that was de previous setting

Have searched for this kind of solution but could not find anything.

Or create the e-mail withour using Word as e-mail editor

Greetings,
Ernst Jan
 
I don't know of a way to do this. Have you considered using CDO?
 
Remou,

Oke will have to look into that.

Thanks for your help

Greetings,
Ernst Jan
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top