Avatar billede jytte Nybegynder
22. maj 2002 - 18:53 Der er 5 kommentarer og
1 løsning

sende HTML-mail vha. CDONTS

Hvordan får jeg en mail til at blive sendt som html vha CDONTS.

Når jeg har følgende asp-fil

<%
dim tekst
tekst= "<!DOCTYPE HTML PUBLIC ""-//IETF//DTD HTML//EN"">" & vbCrLf
tekst = tekst & "<html>"  & vbcrlf
tekst = tekst & "<head>"  & vbcrlf
tekst = tekst & "<meta http-equiv=""Content-Type"" content=""text/html; charset=iso-8859-1"">" & vbcrlf
tekst = tekst & "<title>Sample NewMail</title>"  & vbcrlf
tekst = tekst & "</head>"  & vbcrlf
tekst = tekst & "<body>"  & vbcrlf
tekst = tekst & "Dette er en simpel besked som burde være sendt som HTML. <BR>" & vbcrlf
tekst = tekst & "</body>"  & vbcrlf
tekst = tekst & "</html>"  & vbcrlf

sendmail "jyma@aabc.dk","jyma@aabc.dk",tekst,"test"

function sendmail(TTo,From,text,subject)
  dim oSendMail
  Set oSendMail = CreateObject("CDONTS.Newmail")
  oSendMail.BodyFormat = 0
  oSendMail.From = From
  oSendMail.To =  TTo
  oSendMail.Subject = subject
  oSendMail.Body = text
  oSendMail.Send
  Set oSendMail = Nothing
End Function 'sendmail
%>
---
Får jeg følgende mail:

<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Sample NewMail</title>
</head>
<body>
Dette er en simpel besked som burde være sendt som HTML. <BR>
</body>
</html>
---
Det bliver altså ikke sendt som html ... så hvad gør jeg forkert ?

Avatar billede tuctoh Nybegynder
22. maj 2002 - 18:55 #1
prøv: (er ikke sikker)

oSendMail.BodyFormat = 1
Avatar billede medions Nybegynder
22. maj 2002 - 18:57 #2
here you go:

  <%@ Language=VBScript %>
    <HTML>
    <HEAD>
    <META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
    <%

    Dim myMail
    Dim HTML
    Set myMail = CreateObject("CDONTS.NewMail")

    HTML = "<!DOCTYPE HTML PUBLIC""-//IETF//DTD HTML//EN"">"
    HTML = HTML & "<html>"
    HTML = HTML & "<head>"
    HTML = HTML & "<meta http-equiv=""Content-Type"""
    HTML = HTML & "content=""text/html; charset=iso-8859-1"">"
    HTML = HTML & "<meta name=""GENERATOR"""
    HTML = HTML & " content=""Microsoft Visual Studio 6.0"">"
    HTML = HTML & "<title>HTMLMail</title>"
    HTML = HTML & "</head>"
    HTML = HTML & "<body bgcolor=""FFFFFF"">"
    HTML = HTML & "<IMG src=""http://www.microsoft.com/library/"
    HTML = HTML & "images/gifs/homepage/microsoft.gif"" BORDER=0 "
    HTML = HTML & "WIDTH=167 HEIGHT=36 ALT=""Microsoft Corporation"">"
    HTML = HTML & "<p><font size =""3"" face=""Arial""><strong>"
    HTML = HTML & "Microsoft Exchange CDONTS Example</strong></p>"
    HTML = HTML & "<p><font size =""2"" face=""Tahoma"">"
    HTML = HTML & "CDO for NTS allows an easy way to send mail.<br>"
    HTML = HTML & "This example shows how the content can be "
    HTML = HTML & "an HTML page<br>"
    HTML = HTML & "which allows you to send rich text and"
    HTML = HTML & "inline graphics.</p>"
    HTML = HTML & "</body>"
    HTML = HTML & "</html>"

    myMail.From="someone@microsoft.com"
    myMail.To="someone@microsoft.com"
    myMail.Subject="Sample CDONTS HTML Message"
    myMail.BodyFormat=0
    myMail.MailFormat=0
    myMail.Body=HTML
    myMail.Send
    set mymail=nothing
    Response.Write "Message Sent"
    %>
    </HEAD>
    <BODY>
    </BODY>
    </HTML>

//>Rune
Avatar billede jytte Nybegynder
22. maj 2002 - 18:58 #3
duer ikke,resultatet bliver det samme ...
Avatar billede medions Nybegynder
22. maj 2002 - 18:58 #4
og her har du lidt læse stof til et eksempel oxo hvis det er bedere:

Using CDONTS to send a HTML based email message.

You'll get the general idea..notice how you have to add extra double quotes inside the HTML. You can use any valid HTML. Just make sure you link the images back to your webserver so that the recipient doesn't get a broken image. If the recipient's email program doesn't support HTML this is not always a good way to send email, but most do in my experience and if they don't they will still get the message... it will just look kinda strange.

<%
    Dim MyCDONTSMail2
    Dim HTML
    Set MyCDONTSMail2 = CreateObject("CDONTS.NewMail")
    HTML = "<!DOCTYPE HTML PUBLIC""-//IETF//DTD HTML//EN"">"
    HTML = HTML & "<html>"
    HTML = HTML & "<head>"
    HTML = HTML & "<title>Sending CDONTS Email Using HTML</title>"
    HTML = HTML & "</head>"
    HTML = HTML & "<body bgcolor=""FFFFFF"">"
    HTML = HTML & "<p><font size =""3"" face=""Arial""><strong>"
    HTML = HTML & "Name Of Store</strong><br>"
    HTML = HTML & "Incoming Customer Order</strong></p>"
    HTML = HTML & "<p align = ""center"">Bla Bla Bla Bla Bla</p>"
    HTML = HTML & "</body>"
    HTML = HTML & "</html>"
    MyCDONTSMail2.From= "somebody@somewhere.com"
    MyCDONTSMail2.To="nobody@somewhere.com"
    MyCDONTSMail2.Subject="Incoming Customer Order"
    MyCDONTSMail2.BodyFormat=0
    MyCDONTSMail2.MailFormat=0
    MyCDONTSMail2.Body=HTML
    MyCDONTSMail2.Send
    set MyCDONTSMail2=nothing
%>



//>Rune
Avatar billede jytte Nybegynder
22. maj 2002 - 19:05 #5
tuctoh: min kommentar før var til dig
medions:
  da jeg tilføjede linien
      oSendMail.MailFormat = 0
  virkede!
  TAK SKAL DU HAVE
Avatar billede medions Nybegynder
22. maj 2002 - 19:07 #6
Anytime!
Thx 4 Poinz!
//>Rune
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