Hallo,
ich habe ein Problem mit dem Anhängen einer Datei, da ich nur unter Windows mailen möchte und Strato nun auf SSL umstellt, bin ich noch mal auf die CDO Methode gekommen, die Grundlage dafür ist auf folgender Seite zu finden
http://www.paulsadowski.com/wsh/cdo.htm. Soweit mir bekannt ist SSL in SendMail() von PB noch nicht möglich, ich habe noch ein paar andere Dinge probiert die in den Foren mit der cryptlib.dll laufen sollte, aber der Erfolg war mir nicht geben. Ich nutze die aktuelle PB 5.21 LTS.
Ohne Dateianhang läuft die Methode ja auch und ist ohne viel Aufwand, aber ein Attachment per 'objMessage.AddAttachment "c:\temp\readme.txt"' anzuhängen, klappt nicht
Hat jemand eine Idee woran es liegt?
Code: Alles auswählen
XIncludeFile "COMatePLUS.pbi"
Define.COMateObject objemail,iconf,objbodypart,objbodypart1
objemail = COMate_CreateObject("CDO.Message")
iConf = COMate_CreateObject("CDO.Configuration")
ToAddress.s ="an@mail.de"
SmtpServer.s = "smtp.strato.de"
FromName.s="PB Mailtest "
FromAddress.s ="von@mail.de"
replyto.s ="replay@mail.de"
Subject.s ="Testmail per CDO"
BodyHTML.s ="<h2>Ich bin der Bodytext</h2>"
IPPort.i = 465
ssl.b = 1
timeout.i = 60
Attachment.s = "c:\test.txt"
Username.s="username"
Password.s="passwort"
CcAddress.s
BccAddress.s
If objemail
objemail\SetProperty("Configuration="+ Str(iconf)+ " As COMateObject" )
objemail\SetProperty("MimeFormatted=1" )
objemail\SetProperty("to='"+ ToAddress +"'")
objemail\SetProperty("from='"+Chr(34)+ FromName + Chr(34)+ "<" + FromAddress + ">" +"'")
objemail\SetProperty("Subject='"+Subject+"'")
objemail\SetProperty("HTMLBody="+"'"+BodyHTML+"'")
objemail\SetProperty("replyTo ='"+replyto+"'")
objemail\SetProperty("AddAttachment"+Chr(34)+Attachment+Chr(34)); eigentlich sollte das so OK sein, es kommt aber nichts an....
If CcAddress <> ""
objemail\SetProperty("Cc ='"+ CcAddress +"'")
EndIf
If BccAddress <> ""
objemail\SetProperty("Bcc ='"+ BccAddress +"'")
EndIf
objemail\SetProperty("Configuration\Fields\Item ('http://schemas.microsoft.com/cdo/configuration/sendusing') = 2" )
objemail\SetProperty("Configuration\Fields\Item ('http://schemas.microsoft.com/cdo/configuration/smtpserver') =" +"'"+ SmtpServer+"'" )
objemail\SetProperty("Configuration\Fields\Item ('http://schemas.microsoft.com/cdo/configuration/smtpserverport') ="+IPPort)
objemail\SetProperty("Configuration\Fields\Item ('http://schemas.microsoft.com/cdo/configuration/smtpauthenticate') =1")
objemail\SetProperty("Configuration\Fields\Item ('http://schemas.microsoft.com/cdo/configuration/sendusername') ="+ "'"+ Username+"'")
objemail\SetProperty("Configuration\Fields\Item ('http://schemas.microsoft.com/cdo/configuration/sendpassword') =" +"'"+ Password +"'" )
objemail\SetProperty("Configuration\Fields\Item ('http://schemas.microsoft.com/cdo/configuration/smtpusessl') ="+ssl)
objemail\SetProperty("Configuration\Fields\Item ('http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout') ="+timeout)
Delay(50)
objemail\Invoke("Configuration\Fields\Update")
objemail\invoke("Send")
Debug COMate_GetLastErrorDescription()
objemail\Release()
EndIf