Powershell til ASP
Jeg har nedenstående powershell-script, hvor jeg prøver at få det "oversat" til vb-script der sender via CDO.Indtil nu får jeg dog besked tilbage om at client is not authenticated...
Nogen der har mere held end jeg?
Her er scriptet, længere nede er mit forsøg på et VB-script:
$EmailFrom = "<afsender adresse>"
$EmailTo = "<modtager adresse>"
$Subject = "INDSÆT EMNE HER"
$Body = "INDSÆT BODY HER"
$SMTPServer = "<server ip>"
$SMTPClient = New-Object Net.Mail.SmtpClient($SmtpServer, 587)
#$SMTPClient.EnableSsl = $true
$SMTPClient.Credentials = New-Object System.Net.NetworkCredential("<brugernavn>", "<kodeord>");
$SMTPClient.Send($EmailFrom, $EmailTo, $Subject, $Body)
Function SendMail(strTo, strFrom, strSubject, strMessage, strAccountID, strPassword, strSMTPServer, strSMTPPort, strAuthMethod)
Set ObjSendMail = CreateObject("CDO.Message")
On Error Resume Next
ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2 ' 2 = Send the message using the network (SMTP over the network).
ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserver") = strSMTPServer
ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = strSMTPPort
ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = False 'Use SSL for the connection (True or False)
ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 10
ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = strAuthMethod ' 1 = basic (clear-text) authentication
ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusername") = strAccountID
ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendpassword") = strPassword
ObjSendMail.Configuration.Fields.Update
ObjSendMail.To = strTo
ObjSendMail.Subject = strSubject
ObjSendMail.From = strFrom
ObjSendMail.HTMLBody = strMessage
ObjSendMail.TextBody = strMessage
ObjSendMail.Send
If Err Then Response.Write vbCrLf & vbCrLf & "<h1>SendMail Failed</h1>Error code: <strong>" & Err.Number & "</strong>" & vbCrLf & "Error description: " & vbCrLf & "<strong>" & Err.Description & "</strong>"
On Error Goto 0
Set ObjSendMail = Nothing
End Function