In een mailingapplicatie, gemaakt in klassiek ASP, loop ik tegen het volgende, buitengewoon hinderlijke probleem op. Bij het versturen van de e-mail middels CDO object wordt de e-mail tweemaal verstuurd. Echter, als de property van het mailobject van HTML naar Plain wordt gewijzigd (en de html body als text body wordt verstuurd), verstuurd het systeem de mail gewoon maar 1 keer. Dit heb ik gechecked met twee verschillende smtp objecten, het zit hem dus echt in dit onderscheid.
Ik kan zelf echter geen reden meer verzinnen waarom de mail in HTML formaat tweemail verstuurd zou worden. Anyone?
Onderstaande code wordt aangeroepen op de verzendpagina.
Ik kan zelf echter geen reden meer verzinnen waarom de mail in HTML formaat tweemail verstuurd zou worden. Anyone?
Onderstaande code wordt aangeroepen op de verzendpagina.
ASP:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
| <% sub sendmail ' Get Items for edition sql = "SELECT EditionID, editionDate, Verstuurd, Sent, Recipients FROM Editions WHERE EditionID = " & EditionID set rs = server.createobject("adodb.recordset") with rs .cursortype = adopenkeyset .locktype = adlockoptimistic .cursorlocation = aduseserver .open sql, conn if not .eof then editionDate = .fields("editionDate") verstuurd = .fields("verstuurd") Recipients = trim(.fields("Recipients")) .fields("verstuurd") = true .fields("sent") = Date() .update end if .close end with set rs = nothing thisUrl = Request.ServerVariables("URL") ' Get current URL thisUrl = Replace(thisUrl, "send.asp", "preview.asp?EditionID=" & EditionID) ' Replace URL to retrieve the mailing Set xml = Server.CreateObject("MSXML2.ServerXMLHTTP") ' Create XMLHTTP object to retrieve HTML of mailing With xml .Open "GET", "http://www.domain.ext" & thisUrl, False ' Get the mailing .Send mailtext = .responseText ' Put HTML into variable Set xml = Nothing sch = "http://schemas.microsoft.com/cdo/configuration/" Set cdoConfig = CreateObject("CDO.Configuration") With cdoConfig.Fields .Item(sch & "sendusing") = 1 ' cdoSendUsingPickup=1, cdoSendUsingPort=2 .Item(sch & "smtpserver") = "somewhere.on.theweb" .Item(sch & "smtpconnectiontimeout") = 180 .update End With if EnterRecipients then ' Mode = Enter recipients manually if right(Recipients,1) <> ";" then Recipients = Recipients & ";" end if ' Add last seperator Recipients = replace(Recipients, ";", ",") ' replace possible seperators Recipients = replace(Recipients, VbCrLf, ",") ' replace possible seperators loopRecipients = split(Recipients, ",") ' put recipients in array for i = 0 to ubound(loopRecipients) ' loop trough array Set cdoMessage = CreateObject("CDO.Message") ' Create Message With cdoMessage if len(loopRecipients(i)) then Set .Configuration = cdoConfig ' Set config .From = Name & " (" & Email & ")" ' Set sender (variables are set in previous include file) .To = loopRecipients(i) ' Set To to current array indice .Subject = Name & " " & editionDate ' Set Subject .HTMLBody=Mailtext ' Set HTMLBody On Error Resume Next ' Please continue .Send ' and send the message If Err <> 0 Then ' Did an error occur? response.write "<strong>Niet</strong> verstuurd aan " & loopRecipients(i) & " (" & Err.Description & " )<hr />" Else ' If succesful response.write "Nu verstuurd aan " & loopRecipients(i) & "<hr />" End if response.flush ' Let the user know what's happening end if End With Set cdoMessage = Nothing ' Destroy message Err.Clear ' Clear errors next else ' Mode = Predefined recipient Set cdoMessage = CreateObject("CDO.Message") With cdoMessage Set .Configuration = cdoConfig ' Set config .From = Name & " (" & Email & ")" ' Set sender (variables are set in previous include file) .To = Email ' Set To .Subject = Name & " " & editionDate ' Set Subject .HTMLBody=Mailtext ' Set HTMLBody On Error Resume Next ' Please continue .Send ' and send the message If Err <> 0 Then ' Did an error occur? response.write "<strong>Niet</strong> verstuurd aan " & loopRecipients(i) & " (" & Err.Description & " )<hr />" Else ' If succesfull response.write "Nu verstuurd aan " & loopRecipients(i) & "<hr />" End if response.flush ' Let the user know what's happening End With Set cdoMessage = Nothing end if Set cdoConfig = Nothing response.write "<p>De mailing is verstuurd.</p>" ' All done response.write "<p><a href=""."">Terug</a></p>" end sub %> |
[ Voor 82% gewijzigd door [harm] op 08-10-2007 10:43 ]
Just when I thought I was out, THEY PULL ME BACK IN!