Handtekening HTML email verdwijnt na invoer tekst

Status
Niet open voor verdere reacties.

Scallebe

Gebruiker
Lid geworden
29 okt 2014
Berichten
528
Goede morgen onwikkelaars.

Ik heb op het net een vba code gevonden om een email te creëren vanuit mijn formulier.

Code:
Private Sub Command30_Click()
    Dim myMail As Outlook.MailItem
    Dim myOutlApp As Outlook.Application
    Dim att As Outlook.Attachment

    ' Creating an Outlook-Instance and a new Mailitem
    Set myOutlApp = New Outlook.Application
    Set myMail = myOutlApp.CreateItem(olMailItem)

    With myMail
    
    ' setting the recipient
        '.To =
        '.CC =
        
    ' defining a subject for the mail
        '.Subject =
        
    ' Setting BodyFormat and body-text of the mail
        .BodyFormat = olFormatHTML
        '.HTMLBody = GetHTMLText
        
    ' sending the mail
         .Display
        '.Send
    ' You can as well display the generated mail by calling the Display-Method
    ' of the Mailitem and let the user send it manually later.
    
    End With

    ' terminating the Outlook-Application instance
        'myOutlApp.Quit

    ' Destroy the object variables and free the memory
        Set myMail = Nothing
        Set myOutlApp = Nothing

End Sub

Deze werkt prima met als resultaat een lege mail + mijn handtekening.

Het invullen van de .To, .CC, .Subject geeft geen problemen.

Maar van zodra ik de tekst in .HTMLBody geplaatst heb krijg ik een email, met de ingevoerde tekst, maar zonder de handtekening.

Code:
Private Sub Command29_Click()
    Dim myMail As Outlook.MailItem
    Dim myOutlApp As Outlook.Application
    Dim att As Outlook.Attachment
    Dim stBody As String
    
    ' Creating an Outlook-Instance and a new Mailitem
        Set myOutlApp = New Outlook.Application
        Set myMail = myOutlApp.CreateItem(olMailItem)
    
     With myMail
    ' setting the recipient
        .To = Mid(Me.Email, 1, InStr(1, Me.Email, "#") - 1)
        .CC = Mid(Me.Text33, 1, InStr(1, Me.Text33, "#") - 1) & ";" & Mid(Me.Text36, 1, InStr(1, Me.Text36, "#") - 1)
        
    ' defining a subject for the mail
        .Subject = "Aanvraag verlof & recup - Demande de congé & récup - " & Me.TVoornaam & " " & Me.TNaam
        
    ' Setting BodyFormat and body-text of the mail
        .BodyFormat = olFormatHTML
        .HTMLBody = "Ik vraag - Je demande :" & "<br>" & "<br>" & "<b>" _
        & Me.Hoeveel & "</b>" & " " & "<b>" _
        & Me.Wat.Column(1) & "</b>" & "<br>" & "<br>" _
        & "Op datum van :" & "<br>" & "à la date du :" & "<br>" & "<br>" & "<b>" _
        & Me.Op_datum_van___à_la_date_du & "</b>" _
        & "<br>" & "<br>" & "<u><b>" & "Commentaren - Commentaires" & "</u></b>" & "<br>" & "<br>" _
        & Me.Comment & "<br>" & "<br>" & "<br>" _
        & "Met vriendelijke groeten / Cordialement" & "<br>" & "<br>" _
        & Me.TVoornaam & " " & Me.TNaam

    ' sending the mail
        .Display
        '.Send
    ' You can as well display the generated mail by calling the Display-Method
    ' of the Mailitem and let the user send it manually later.
    
    End With

    ' terminating the Outlook-Application instance
        'myOutlApp.Quit

    ' Destroy the object variables and free the memory
        Set myMail = Nothing
        Set myOutlApp = Nothing
        
End Sub

Hoe komt dat en hoe moet ik dit aanpassen?

Thanks

Greetz

Pascal
 
Doe het eens zo:
Code:
     With myMail
[COLOR="#FF0000"]        .Display
        stBody = .HTMLBody
[/COLOR]        .BodyFormat = olFormatHTML
        .HTMLBody = "Ik vraag - Je demande :" & "<br>" & "<br>" & "<b>" [COLOR="#FF0000"]& stBody[/COLOR]
 
edmoor,

Badankt,

Dat is het. Werkt prima... :thumb:


Greetz

Pascal
 
Status
Niet open voor verdere reacties.
Steun Ons

Nieuwste berichten

Terug
Bovenaan Onderaan