Avatar billede nph12 Nybegynder
09. juli 2008 - 20:19 Der er 5 kommentarer og
1 løsning

VBA: lav html-mail

Hej
Hvordan laver jeg en html-mail i VBA?
Avatar billede wosgam Nybegynder
09. juli 2008 - 20:46 #1
Sådan her:

' VB source code to create a simple HTML email and send it.
' This example manually builds the HTML mail.

' (An alternative is to use the Chilkat MHT component in conjunction with
' Chilkat Mail to automate the creation of HTML mail from
' HTML files or Web pages (URLs).)
Private Sub Command1_Click()
   
    ' Create a mailman object for sending HTML email
    Dim mailman As ChilkatMailMan2
    Set mailman = New ChilkatMailMan2
   
    mailman.UnlockComponent "Anything works to start 30-day trial"
   
    ' Set the SMTP host.
    mailman.SmtpHost = "smtp.comcast.net"
   
    ' Only set the username/password if the SMTP server requires it.
    'mailman.SmtpUsername = "my_username"
    'mailman.SmtpPassword = "my_password"
   
    ' Create the email, add content, address it, and sent it.
    Dim email As ChilkatEmail2
    Set email = New ChilkatEmail2
    email.AddTo "Chilkat Admin", "admin@chilkatsoft.com"
    email.AddTo "Chilkat Gmail", "chilkat.support@gmail.com"
    email.AddTo "Chilkat Yahoo", "chilkat_software@yahoo.com"
    email.subject = "This is a test"
   
    imageContentID = email.AddRelatedFile("c:/temp/dude.gif")
   
    email.SetHtmlBody ("<!DOCTYPE HTML PUBLIC " & Chr(34) & _
        "-//W3C//DTD HTML 4.0 Transitional//EN" & Chr(34) & _
        "><HTML><HEAD></HEAD><BODY>" & _
"<br>This is an example of embedding an image in HTML email.<BR><IMG SRC=" & _
Chr(34) & "cid:" & imageContentID & Chr(34) & _
"><br>(The content ID of the image looks like this: " & _
imageContentID & "<br>The <b>HTML</b> for embedding the image looks like this: <img src=" & _
Chr(34) & "cid:" & imageContentID & Chr(34) & "><br></BODY></HTML>")
   
    email.AddPlainTextAlternativeBody "This is the plain text"
   
    email.From = "support@chilkatsoft.com"
       
    ' Call SendEmail to send HTML email.
    success = mailman.SendEmail(email)
    If (success = 1) Then
        MsgBox "Mail Sent!"
    Else
        MsgBox mailman.LastErrorText
    End If
   
    Set email = Nothing
    Set mailman = Nothing
   
End Sub


er taget direkte fra: http://www.example-code.com/vb/vbSendHtml1.asp
i code blokken.
Avatar billede nph12 Nybegynder
09. juli 2008 - 21:04 #2
Ups. Det er hvis mig som er lidt uklar. VBA-kode for html-mailen skal sendes/bruges i Outlook.
Avatar billede arne_v Ekspert
10. juli 2008 - 02:16 #3
Og ovenstående er til ASP/VBS med en Chilkat komponent installeret.
Avatar billede nph12 Nybegynder
10. juli 2008 - 18:52 #5
OK. Arne v, opret et svar, hvis du vil have point
Avatar billede arne_v Ekspert
10. juli 2008 - 19:11 #6
svar
Avatar billede Ny bruger Nybegynder

Din løsning...

Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.

Loading billede Opret Preview
Kategori
Kurser inden for grundlæggende programmering

Log ind eller opret profil

Hov!

For at kunne deltage på Computerworld Eksperten skal du være logget ind.

Det er heldigvis nemt at oprette en bruger: Det tager to minutter og du kan vælge at bruge enten e-mail, Facebook eller Google som login.

Du kan også logge ind via nedenstående tjenester