Что нового

отправка почты через прокси

Tiberium6

Новичок
Сообщения
51
Репутация
0
Код:
; Include
#Include<file.au3>
$SmtpServer = "mail.mail.ru"       ; address for the smtp-server to use - REQUIRED
$FromName = "[email protected]"         ; name from who the email was sent
$FromAddress = "[email protected]"      ; address from where the mail should come
$ToAddress = "[email protected]"        ; destination address of the email - REQUIRED
$Subject = "Userinfo"                     ; subject from the email - can be anything you want it to be
$Body = ""                                ; the messagebody from the mail - can be left blank but then you get a blank mail
$AttachFiles = "C:\111.txt"               ; the file(s) you want to attach seperated with a ; (Semicolon) - leave blank if not needed
$CcAddress = "[email protected]"        ; address for cc - leave blank if not needed
$BccAddress = "[email protected]"       ; address for bcc - leave blank if not needed
$Importance = "Normal"                    ; Send message priority: "High", "Normal", "Low"
$Username = "[email protected]"         ; username for the account used from where the mail gets sent - REQUIRED
$Password = "pass"                 ; password for the account used from where the mail gets sent - REQUIRED
$IPPort = 25                              ; port used for sending the mail
$ssl = 0                                  ; enables/disables secure socket layer sending - put to 1 if using httpS
;~ $IPPort=465                            ; GMAIL port used for sending the mail
;~ $ssl=1                                 ; GMAILenables/disables secure socket layer sending - put to 1 if using httpS

;##################################
; Script
;##################################
Global $oMyRet[2]
Global $oMyError = ObjEvent("AutoIt.Error", "MyErrFunc")
$rc = _INetSmtpMailCom($SmtpServer, $FromName, $FromAddress, $ToAddress, $Subject, $Body, $AttachFiles, $CcAddress, $BccAddress, $Importance, $Username, $Password, $IPPort, $ssl)
If @error Then
    MsgBox(0, "Error sending message", "Error code:" & @error & "  Description:" & $rc)
EndIf
;
; The UDF
Func _INetSmtpMailCom($s_SmtpServer, $s_FromName, $s_FromAddress, $s_ToAddress, $s_Subject = "", $as_Body = "", $s_AttachFiles = "", $s_CcAddress = "", $s_BccAddress = "", $s_Importance="Normal", $s_Username = "", $s_Password = "", $IPPort = 25, $ssl = 0)
    Local $objEmail = ObjCreate("CDO.Message")
    $objEmail.From = '"' & $s_FromName & '" <' & $s_FromAddress & '>'
    $objEmail.To = $s_ToAddress
    Local $i_Error = 0
    Local $i_Error_desciption = ""
    If $s_CcAddress <> "" Then $objEmail.Cc = $s_CcAddress
    If $s_BccAddress <> "" Then $objEmail.Bcc = $s_BccAddress
    $objEmail.Subject = $s_Subject
    If StringInStr($as_Body, "<") And StringInStr($as_Body, ">") Then
        $objEmail.HTMLBody = $as_Body
    Else
        $objEmail.Textbody = $as_Body & @CRLF
    EndIf
    If $s_AttachFiles <> "" Then
        Local $S_Files2Attach = StringSplit($s_AttachFiles, ";")
        For $x = 1 To $S_Files2Attach[0]
            $S_Files2Attach[$x] = _PathFull($S_Files2Attach[$x])
;~          ConsoleWrite('@@ Debug : $S_Files2Attach[$x] = ' & $S_Files2Attach[$x] & @LF & '>Error code: ' & @error & @LF) ;### Debug Console
            If FileExists($S_Files2Attach[$x]) Then
                ConsoleWrite('+> File attachment added: ' & $S_Files2Attach[$x] & @LF)
                $objEmail.AddAttachment($S_Files2Attach[$x])
            Else
                ConsoleWrite('!> File not found to attach: ' & $S_Files2Attach[$x] & @LF)
                SetError(1)
                Return 0
            EndIf
        Next
    EndIf
    $objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
    $objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserver") = $s_SmtpServer
    If Number($IPPort) = 0 then $IPPort = 25
    $objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = $IPPort
    ;Authenticated SMTP
    If $s_Username <> "" Then
        $objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1
        $objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusername") = $s_Username
        $objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendpassword") = $s_Password
    EndIf
    If $ssl Then
        $objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = True
    EndIf
    ;Update settings
    $objEmail.Configuration.Fields.Update
    ; Set Email Importance
    Switch $s_Importance
        Case "High"
            $objEmail.Fields.Item ("urn:schemas:mailheader:Importance") = "High"
        Case "Normal"
            $objEmail.Fields.Item ("urn:schemas:mailheader:Importance") = "Normal"
        Case "Low"
            $objEmail.Fields.Item ("urn:schemas:mailheader:Importance") = "Low"
    EndSwitch
    $objEmail.Fields.Update
    ; Sent the Message
    $objEmail.Send
    If @error Then
        SetError(2)
        Return $oMyRet[1]
    EndIf
    $objEmail=""
EndFunc   ;==>_INetSmtpMailCom
;
;
; Com Error Handler
Func MyErrFunc()
    $HexNumber = Hex($oMyError.number, 8)
    $oMyRet[0] = $HexNumber
    $oMyRet[1] = StringStripWS($oMyError.description, 3)
    ConsoleWrite("### COM Error !  Number: " & $HexNumber & "   ScriptLine: " & $oMyError.scriptline & "   Description:" & $oMyRet[1] & @LF)
    SetError(1); something to check for when this function returns
    Return
EndFunc   ;==>MyErrFunc


интернет работает через proxy, пытаюсь отправить письмо и выходит ошибка: транспорту не удалось подключиться к серверу. Скрипт работает только на компьютере где поставил Proxifier. как сделать что бы отправлялись письма через proxy?
 

joiner

Модератор
Локальный модератор
Сообщения
3,556
Репутация
628
настроить прокси в системе
или искать на форуме http://autoit-script.ru/index.php/topic,917.0.html
 
Автор
T

Tiberium6

Новичок
Сообщения
51
Репутация
0
все настроено, proxy прописан, интернет работает, но почта не отправляется.... есть подозрения что в скрипте нужно прописать работу чрез proxy
Код:
HttpSetProxy(0)
но я не знаю как и куда ...
 

joiner

Модератор
Локальный модератор
Сообщения
3,556
Репутация
628
вот пример моей переделки одной почтовой программы .http://autoit-script.ru/index.php/topic,8767.msg59082.html#msg59082
в сообщении есть прикрепленный файл . программа не только отправляет файл на почту, но и создает агента по постоянной отправке. в архиве два файла.работает через прокси, если сами настройки прокси есть в системе.
в этот пример я прикручивал код авторизации на прокси (пример не сохранился. но склеить не сложно) из этого сообщения http://autoit-script.ru/index.php/topic,917.msg6517.html#msg6517
тогда можно отправлять , делая авторизацию на прокси минуя настройки системы.
 
Автор
T

Tiberium6

Новичок
Сообщения
51
Репутация
0
joiner спасибо :smile: я проверил с помощью
Код:
$sAdress = "google.ru" 
While 1 
    $iResult = Ping ($sAdress) 
    ConsoleWrite ("Ответ от: "&$sAdress&": время "&$iResult&"мс" & @CRLF) 
	MsgBox (0,"",$iResult)
    sleep(1500); пауза 1,5 сек 
WEnd

проверил интернет, на том компьютере не пингует, думаю с proxy дело.
 

joiner

Модератор
Локальный модератор
Сообщения
3,556
Репутация
628
Tiberium6
Пинг через прокси не проходит. не через функцию
Код:
Ping

не через системный ping
я использовал прогу, на которую дал ссылку на работе через прокси. в самой программе настроек не было. но система была настроена на прокси. все работало.
 
Автор
T

Tiberium6

Новичок
Сообщения
51
Репутация
0
Код:
#include <ButtonConstants.au3>
#include <ComboConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#Include<file.au3>

#Region ### START Koda GUI section ### Form=
$Form1_2 = GUICreate("Form1", 500, 480, 219, 136)
$Label12 = GUICtrlCreateLabel("", 170, 400, 196, 28)
GUICtrlSetFont(-1, 14, 400, 0, "MS Sans Serif")
$Label1 = GUICtrlCreateLabel("Куда:", 40, 16, 31, 17)
$Label2 = GUICtrlCreateLabel("Тема письма:", 40, 48, 75, 17)
$Combo1 = GUICtrlCreateCombo("", 120, 16, 217, 25)
GUICtrlSetData(-1, "|[email protected]", "[email protected]") ; почтовые адреса
$Input1 = GUICtrlCreateInput("", 120, 45, 217, 21)
$Button1 = GUICtrlCreateButton("Отправить", 175, 440, 155, 25)
$Group1 = GUICtrlCreateGroup("Файлы", 32, 72, 435, 305)
$Button2 = GUICtrlCreateButton("Файл1", 40, 88, 75, 25)
$Button3 = GUICtrlCreateButton("Файл2", 40, 120, 75, 25)
$Button4 = GUICtrlCreateButton("Файл3", 40, 152, 75, 25)
$Button5 = GUICtrlCreateButton("Файл4", 40, 184, 75, 25)
$Button6 = GUICtrlCreateButton("Файл5", 40, 216, 75, 25)
$Button7 = GUICtrlCreateButton("Файл6", 40, 248, 75, 25)
$Button8 = GUICtrlCreateButton("Файл7", 40, 280, 75, 25)
$Button9 = GUICtrlCreateButton("Файл8", 40, 312, 75, 25)
$Button10 = GUICtrlCreateButton("Файл9", 40, 344, 75, 25)
$Button11 = GUICtrlCreateButton("удалить", 382, 88, 75, 25)
$Button12 = GUICtrlCreateButton("удалить", 382, 122, 75, 25)
$Button13 = GUICtrlCreateButton("удалить", 382, 152, 75, 25)
$Button14 = GUICtrlCreateButton("удалить", 382, 184, 75, 25)
$Button15 = GUICtrlCreateButton("удалить", 382, 216, 75, 25)
$Button16 = GUICtrlCreateButton("удалить", 382, 248, 75, 25)
$Button17 = GUICtrlCreateButton("удалить", 382, 280, 75, 25)
$Button18 = GUICtrlCreateButton("удалить", 382, 312, 75, 25)
$Button19 = GUICtrlCreateButton("удалить", 382, 344, 75, 25)
$Label3 = GUICtrlCreateLabel("", 122, 96, 252, 17,$WS_EX_STATICEDGE)
GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0x0066CC)
$Label4 = GUICtrlCreateLabel("", 122, 126, 252, 17,$WS_EX_STATICEDGE)
GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0x0066CC)
$Label5 = GUICtrlCreateLabel("", 122, 158, 252, 17,$WS_EX_STATICEDGE)
GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0x0066CC)
$Label6 = GUICtrlCreateLabel("", 122, 190, 252, 17,$WS_EX_STATICEDGE)
GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0x0066CC)
$Label7 = GUICtrlCreateLabel("", 122, 221, 252, 17,$WS_EX_STATICEDGE)
GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0x0066CC)
$Label8 = GUICtrlCreateLabel("", 122, 252, 252, 17,$WS_EX_STATICEDGE)
GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0x0066CC)
$Label9 = GUICtrlCreateLabel("", 122, 286, 252, 17,$WS_EX_STATICEDGE)
GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0x0066CC)
$Label10 = GUICtrlCreateLabel("", 122, 318, 252, 17,$WS_EX_STATICEDGE)
GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0x0066CC)
$Label11 = GUICtrlCreateLabel("", 122, 348, 252, 17,$WS_EX_STATICEDGE)
GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0x0066CC)
GUICtrlCreateGroup("", -99, -99, 1, 1)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###


;~ Global $UseIntegratedSecurity = False
;~ Global $ProxyServer = "192.168.1.202:8080"
;~ Global $ProxyUser = "belousovev" ;if $UseIntegratedSecurity is true (and working), these can be blank
;~ Global $ProxyPass = "Gfhjkm21"
;~ Global $oHttp = ObjCreate ("WinHttp.WinHttpRequest.5.1")
;~ $oHttp.SetProxy(2,$ProxyServer) ; PRECONFIG = 0 (default), DIRECT = 1, PROXY = 2
$Proxy= HttpSetProxy(2,"192.168.1.202:8080","user","pAAS")
	$FilePath1 = ""
	$FilePath2 = ""
	$FilePath3 = ""
	$FilePath4 = ""
	$FilePath5 = ""
	$FilePath6 = ""
	$FilePath7 = ""
	$FilePath8 = ""
	$FilePath9 = ""

While 1

	$nMsg = GUIGetMsg()


	Switch $nMsg
		Case $GUI_EVENT_CLOSE
			Exit
		case $Button2

$FilePath1 = FileOpenDialog("ВЫБЕРИТЕ ФАЙЛ ДЛЯ ОТПРАВКИ", "Z:", "All (*.*)", 3)
$pos=StringInStr($FilePath1,"\",0,-1)
$Fname=StringMid($FilePath1,$pos,StringLen($FilePath1)-$pos+1)
$var = StringMid($Fname, 2, 100)
GUICtrlSetData($Label3, $var)
if $FilePath1 ="" Then
else
GUICtrlSetState($Button2, $GUI_DISABLE)
EndIf
		case $Button3

$FilePath2 = FileOpenDialog("ВЫБЕРИТЕ ФАЙЛ ДЛЯ ОТПРАВКИ", "Z:", "All (*.*)", 3)
$pos=StringInStr($FilePath2,"\",0,-1)
$Fname=StringMid($FilePath2,$pos,StringLen($FilePath2)-$pos+1)
$var = StringMid($Fname, 2, 100)
GUICtrlSetData($Label4, $var)
if $FilePath2 ="" Then
else
GUICtrlSetState($Button3, $GUI_DISABLE)
EndIf

		case $Button4

$FilePath3 = FileOpenDialog("ВЫБЕРИТЕ ФАЙЛ ДЛЯ ОТПРАВКИ", "Z:", "All (*.*)", 3)
$pos=StringInStr($FilePath3,"\",0,-1)
$Fname=StringMid($FilePath3,$pos,StringLen($FilePath3)-$pos+1)
$var = StringMid($Fname, 2, 100)
GUICtrlSetData($Label5, $var)
if $FilePath3 ="" Then
else
GUICtrlSetState($Button4, $GUI_DISABLE)
EndIf
		case $Button5

$FilePath4 = FileOpenDialog("ВЫБЕРИТЕ ФАЙЛ ДЛЯ ОТПРАВКИ", "Z:", "All (*.*)", 3)
$pos=StringInStr($FilePath4,"\",0,-1)
$Fname=StringMid($FilePath4,$pos,StringLen($FilePath4)-$pos+1)
$var = StringMid($Fname, 2, 100)
GUICtrlSetData($Label6, $var)
if $FilePath4 ="" Then
else
GUICtrlSetState($Button5, $GUI_DISABLE)
EndIf

		case $Button6

$FilePath5 = FileOpenDialog("ВЫБЕРИТЕ ФАЙЛ ДЛЯ ОТПРАВКИ", "Z:", "All (*.*)", 3)
$pos=StringInStr($FilePath5,"\",0,-1)
$Fname=StringMid($FilePath5,$pos,StringLen($FilePath5)-$pos+1)
$var = StringMid($Fname, 2, 100)
GUICtrlSetData($Label7, $var)
if $FilePath5 ="" Then
else
GUICtrlSetState($Button6, $GUI_DISABLE)
EndIf

		case $Button7

$FilePath6 = FileOpenDialog("ВЫБЕРИТЕ ФАЙЛ ДЛЯ ОТПРАВКИ", "Z:", "All (*.*)", 3)
$pos=StringInStr($FilePath6,"\",0,-1)
$Fname=StringMid($FilePath6,$pos,StringLen($FilePath6)-$pos+1)
$var = StringMid($Fname, 2, 100)
GUICtrlSetData($Label8, $var)
if $FilePath6 ="" Then
else
GUICtrlSetState($Button7, $GUI_DISABLE)
EndIf

		case $Button8

$FilePath7 = FileOpenDialog("ВЫБЕРИТЕ ФАЙЛ ДЛЯ ОТПРАВКИ", "Z:", "All (*.*)", 3)
$pos=StringInStr($FilePath7,"\",0,-1)
$Fname=StringMid($FilePath7,$pos,StringLen($FilePath7)-$pos+1)
$var = StringMid($Fname, 2, 100)
GUICtrlSetData($Label9, $var)
if $FilePath7 ="" Then
else
GUICtrlSetState($Button8, $GUI_DISABLE)
EndIf

		case $Button9

$FilePath8 = FileOpenDialog("ВЫБЕРИТЕ ФАЙЛ ДЛЯ ОТПРАВКИ", "Z:", "All (*.*)", 3)
$pos=StringInStr($FilePath8,"\",0,-1)
$Fname=StringMid($FilePath8,$pos,StringLen($FilePath8)-$pos+1)
$var = StringMid($Fname, 2, 100)
GUICtrlSetData($Label10, $var)
if $FilePath8 ="" Then
else
GUICtrlSetState($Button9, $GUI_DISABLE)
EndIf

		case $Button10

$FilePath9 = FileOpenDialog("ВЫБЕРИТЕ ФАЙЛ ДЛЯ ОТПРАВКИ", "Z:", "All (*.*)", 3)
$pos=StringInStr($FilePath9,"\",0,-1)
$Fname=StringMid($FilePath9,$pos,StringLen($FilePath9)-$pos+1)
$var = StringMid($Fname, 2, 100)
GUICtrlSetData($Label11, $var)
if $FilePath9 ="" Then
else
GUICtrlSetState($Button10, $GUI_DISABLE)
EndIf

		case $Button11

			GUICtrlSetData ($Label3,"")
			GUICtrlSetState($Button2,$GUI_ENABLE)

		case $Button12

			GUICtrlSetData ($Label4,"")
			GUICtrlSetState($Button3,$GUI_ENABLE)

		case $Button13

			GUICtrlSetData ($Label5,"")
			GUICtrlSetState($Button4,$GUI_ENABLE)

		case $Button14

			GUICtrlSetData ($Label6,"")
			GUICtrlSetState($Button5,$GUI_ENABLE)

		case $Button15

			GUICtrlSetData ($Label7,"")
			GUICtrlSetState($Button6,$GUI_ENABLE)

		case $Button16

			GUICtrlSetData ($Label8,"")
			GUICtrlSetState($Button7,$GUI_ENABLE)

		case $Button17

			GUICtrlSetData ($Label9,"")
			GUICtrlSetState($Button8,$GUI_ENABLE)

		case $Button18

			GUICtrlSetData ($Label10,"")
			GUICtrlSetState($Button9,$GUI_ENABLE)

		case $Button19

			GUICtrlSetData ($Label11,"")
			GUICtrlSetState($Button10,$GUI_ENABLE)


		case $Button1


Dim $FilePath[9], $SendStr = ""
$FilePath[0] = $FilePath1
$FilePath[1] = $FilePath2
$FilePath[2] = $FilePath3
$FilePath[3] = $FilePath4
$FilePath[4] = $FilePath5
$FilePath[5] = $FilePath6
$FilePath[6] = $FilePath7
$FilePath[7] = $FilePath8
$FilePath[8] = $FilePath9

For $i=0 To 8
  If $FilePath[$i] <> "" Then $SendStr &= $FilePath[$i] & ";"
Next
If $SendStr <> "" Then $SendStr = StringTrimRight($SendStr, 1)
ConsoleWrite($SendStr & @CRLF)



$fileadd = $SendStr

$SmtpServer = "1111"       ; address for the smtp-server to use - REQUIRED
$FromName = "1111"         ; name from who the email was sent
$FromAddress = "1111"      ; address from where the mail should come
$ToAddress = GUICtrlRead ($Combo1)       ; destination address of the email - REQUIRED
$Subject = GUICtrlRead ($Input1)          ; subject from the email - can be anything you want it to be
$Body = ""                                ; the messagebody from the mail - can be left blank but then you get a blank mail
$AttachFiles = $fileadd                 ; the file(s) you want to attach seperated with a ; (Semicolon) - leave blank if not needed
$CcAddress = "1111"        ; address for cc - leave blank if not needed
$BccAddress = "1111"       ; address for bcc - leave blank if not needed
$Importance = "Normal"                    ; Send message priority: "High", "Normal", "Low"
$Username = "1111"         ; username for the account used from where the mail gets sent - REQUIRED
$Password = "1111"                 ; password for the account used from where the mail gets sent - REQUIRED
$IPPort = 25                              ; port used for sending the mail
$ssl = 0                                  ; enables/disables secure socket layer sending - put to 1 if using httpS
;~ $IPPort=465                            ; GMAIL port used for sending the mail
;~ $ssl=1                                 ; GMAILenables/disables secure socket layer sending - put to 1 if using httpS

;##################################
; Script
;##################################
GUICtrlSetData ($Label12,"ОТПРАВЛЯЕТСЯ.......")
Global $oMyRet[2]
Global $oMyError = ObjEvent("AutoIt.Error", "MyErrFunc")
$rc = _INetSmtpMailCom($SmtpServer, $FromName, $FromAddress, $ToAddress, $Subject, $Body, $AttachFiles, $CcAddress, $BccAddress, $Importance, $Username, $Password, $IPPort, $ssl)
GUICtrlSetData ($Label12,"!!!ОТПРАВЛЕНО!!!")
sleep (5000)
GUICtrlSetData ($Label3,"")
GUICtrlSetData ($Label4,"")
GUICtrlSetData ($Label5,"")
GUICtrlSetData ($Label6,"")
GUICtrlSetData ($Label7,"")
GUICtrlSetData ($Label8,"")
GUICtrlSetData ($Label9,"")
GUICtrlSetData ($Label10,"")
GUICtrlSetData ($Label11,"")
GUICtrlSetData ($Label12,"")
GUICtrlSetState($Button1,$GUI_ENABLE)
GUICtrlSetState($Button2,$GUI_ENABLE)
GUICtrlSetState($Button3,$GUI_ENABLE)
GUICtrlSetState($Button4,$GUI_ENABLE)
GUICtrlSetState($Button5,$GUI_ENABLE)
GUICtrlSetState($Button6,$GUI_ENABLE)
GUICtrlSetState($Button7,$GUI_ENABLE)
GUICtrlSetState($Button8,$GUI_ENABLE)
GUICtrlSetState($Button9,$GUI_ENABLE)
GUICtrlSetState($Button10,$GUI_ENABLE)

	EndSwitch
WEnd

Func _INetSmtpMailCom($s_SmtpServer, $s_FromName, $s_FromAddress, $s_ToAddress, $s_Subject = "", $as_Body = "", $s_AttachFiles = "", $s_CcAddress = "", $s_BccAddress = "", $s_Importance="Normal", $s_Username = "", $s_Password = "", $IPPort = 25, $ssl = 0)
    Local $objEmail = ObjCreate("CDO.Message")
    $objEmail.From = '"' & $s_FromName & '" <' & $s_FromAddress & '>'
    $objEmail.To = $s_ToAddress
    Local $i_Error = 0
    Local $i_Error_desciption = ""
    If $s_CcAddress <> "" Then $objEmail.Cc = $s_CcAddress
    If $s_BccAddress <> "" Then $objEmail.Bcc = $s_BccAddress
    $objEmail.Subject = $s_Subject
    If StringInStr($as_Body, "<") And StringInStr($as_Body, ">") Then
        $objEmail.HTMLBody = $as_Body
    Else
        $objEmail.Textbody = $as_Body & @CRLF
    EndIf
    If $s_AttachFiles <> "" Then
        Local $S_Files2Attach = StringSplit($s_AttachFiles, ";")
        For $x = 1 To $S_Files2Attach[0]
            $S_Files2Attach[$x] = _PathFull($S_Files2Attach[$x])
;~          ConsoleWrite('@@ Debug : $S_Files2Attach[$x] = ' & $S_Files2Attach[$x] & @LF & '>Error code: ' & @error & @LF) ;### Debug Console
            If FileExists($S_Files2Attach[$x]) Then
                ConsoleWrite('+> File attachment added: ' & $S_Files2Attach[$x] & @LF)
                $objEmail.AddAttachment($S_Files2Attach[$x])
            Else
                ConsoleWrite('!> File not found to attach: ' & $S_Files2Attach[$x] & @LF)
                SetError(1)
                Return 0
            EndIf
        Next
    EndIf
    $objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
    $objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserver") = $s_SmtpServer
    If Number($IPPort) = 0 then $IPPort = 25
    $objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = $IPPort
    ;Authenticated SMTP
    If $s_Username <> "" Then
        $objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1
        $objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusername") = $s_Username
        $objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendpassword") = $s_Password
    EndIf
    If $ssl Then
        $objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = True
    EndIf
    ;Update settings
    $objEmail.Configuration.Fields.Update
    ; Set Email Importance
    Switch $s_Importance
        Case "High"
            $objEmail.Fields.Item ("urn:schemas:mailheader:Importance") = "High"
        Case "Normal"
            $objEmail.Fields.Item ("urn:schemas:mailheader:Importance") = "Normal"
        Case "Low"
            $objEmail.Fields.Item ("urn:schemas:mailheader:Importance") = "Low"
    EndSwitch
    $objEmail.Fields.Update
    ; Sent the Message
    $objEmail.Send
    If @error Then
        SetError(2)
        Return $oMyRet[1]
    EndIf
    $objEmail=""
EndFunc   ;==>_INetSmtpMailCom
;
;
; Com Error Handler
Func MyErrFunc()
    $HexNumber = Hex($oMyError.number, 8)
    $oMyRet[0] = $HexNumber
    $oMyRet[1] = StringStripWS($oMyError.description, 3)
    ConsoleWrite("### COM Error !  Number: " & $HexNumber & "   ScriptLine: " & $oMyError.scriptline & "   Description:" & $oMyRet[1] & @LF)
    SetError(1); something to check for when this function returns
    Return
EndFunc   ;==>MyErrFunc

так и не смог приделать прокси, как сделать что бы почта работала через proxy? только не брала автоматом с IE настройки прокси
 

araneon

Новичок
Сообщения
59
Репутация
0
Привет всем
Понимаю что тема давнишная но мало ли.
Подскажите почему у меня код отрабатывает нормально а вот на другой машине не работает, пишет

Error code:2 Description:Транспорту не удалось подключиться к серверу. :stars:

Обе системы Windows 7 32bit, Outlook 2010, сеть через прокси, но использую локальный SMTP сервер.

Код:
;
;##################################
; Include
;##################################
#Include<file.au3>
;##################################
; Variables
;##################################
$SmtpServer = "10.233.200.110"              ; address for the smtp-server to use - REQUIRED
$FromName = ""                      ; name from who the email was sent
$FromAddress = "TEST" ; address from where the mail should come
$ToAddress = @UserName&"@domen.ru"   ; destination address of the email - REQUIRED
$Subject = @ComputerName                 ; subject from the email - can be anything you want it to be
$Body = "Тестовое письмо !"                              ; the messagebody from the mail - can be left blank but then you get a blank mail
$AttachFiles = ""                       ; the file(s) you want to attach seperated with a ; (Semicolon) - leave blank if not needed
$CcAddress = ""       ; address for cc - leave blank if not needed
$BccAddress = ""     ; address for bcc - leave blank if not needed
$Importance = "Normal"                  ; Send message priority: "High", "Normal", "Low"
$Username = ""                    ; username for the account used from where the mail gets sent - REQUIRED
$Password = ""                  ; password for the account used from where the mail gets sent - REQUIRED
$IPPort = 25                            ; port used for sending the mail
$ssl = 0                                ; enables/disables secure socket layer sending - put to 1 if using httpS
;~ $IPPort=465                          ; GMAIL port used for sending the mail
;~ $ssl=1                               ; GMAILenables/disables secure socket layer sending - put to 1 if using httpS

;##################################
; Script
;##################################
Global $oMyRet[2]
Global $oMyError = ObjEvent("AutoIt.Error", "MyErrFunc")
$rc = _INetSmtpMailCom($SmtpServer, $FromName, $FromAddress, $ToAddress, $Subject, $Body, $AttachFiles, $CcAddress, $BccAddress, $Importance, $Username, $Password, $IPPort, $ssl)
If @error Then
    MsgBox(0, "Error sending message", "Error code:" & @error & "  Description:" & $rc)
EndIf
;
; The UDF
Func _INetSmtpMailCom($s_SmtpServer, $s_FromName, $s_FromAddress, $s_ToAddress, $s_Subject = "", $as_Body = "", $s_AttachFiles = "", $s_CcAddress = "", $s_BccAddress = "", $s_Importance="Normal", $s_Username = "", $s_Password = "", $IPPort = 25, $ssl = 0)
    Local $objEmail = ObjCreate("CDO.Message")
    $objEmail.From = '"' & $s_FromName & '" <' & $s_FromAddress & '>'
    $objEmail.To = $s_ToAddress
    Local $i_Error = 0
    Local $i_Error_desciption = ""
    If $s_CcAddress <> "" Then $objEmail.Cc = $s_CcAddress
    If $s_BccAddress <> "" Then $objEmail.Bcc = $s_BccAddress
    $objEmail.Subject = $s_Subject
    If StringInStr($as_Body, "<") And StringInStr($as_Body, ">") Then
        $objEmail.HTMLBody = $as_Body
    Else
        $objEmail.Textbody = $as_Body & @CRLF
    EndIf
    If $s_AttachFiles <> "" Then
        Local $S_Files2Attach = StringSplit($s_AttachFiles, ";")
        For $x = 1 To $S_Files2Attach[0]
            $S_Files2Attach[$x] = _PathFull($S_Files2Attach[$x])
;~          ConsoleWrite('@@ Debug : $S_Files2Attach[$x] = ' & $S_Files2Attach[$x] & @LF & '>Error code: ' & @error & @LF) ;### Debug Console
            If FileExists($S_Files2Attach[$x]) Then
                ConsoleWrite('+> File attachment added: ' & $S_Files2Attach[$x] & @LF)
                $objEmail.AddAttachment($S_Files2Attach[$x])
            Else
                ConsoleWrite('!> File not found to attach: ' & $S_Files2Attach[$x] & @LF)
                SetError(1)
                Return 0
            EndIf
        Next
    EndIf
    $objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
    $objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserver") = $s_SmtpServer
    If Number($IPPort) = 0 then $IPPort = 25
    $objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = $IPPort
    ;Authenticated SMTP
    If $s_Username <> "" Then
        $objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1
        $objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusername") = $s_Username
        $objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendpassword") = $s_Password
    EndIf
    If $ssl Then
        $objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = True
    EndIf
    ;Update settings
    $objEmail.Configuration.Fields.Update
    ; Set Email Importance
    Switch $s_Importance
        Case "High"
            $objEmail.Fields.Item ("urn:schemas:mailheader:Importance") = "High"
        Case "Normal"
            $objEmail.Fields.Item ("urn:schemas:mailheader:Importance") = "Normal"
        Case "Low"
            $objEmail.Fields.Item ("urn:schemas:mailheader:Importance") = "Low"
    EndSwitch
    $objEmail.Fields.Update
    ; Sent the Message
    $objEmail.Send
    If @error Then
        SetError(2)
        Return $oMyRet[1]
    EndIf
    $objEmail=""
EndFunc   ;==>_INetSmtpMailCom
;
;
; Com Error Handler
Func MyErrFunc()
    $HexNumber = Hex($oMyError.number, 8)
    $oMyRet[0] = $HexNumber
    $oMyRet[1] = StringStripWS($oMyError.description, 3)
    ConsoleWrite("### COM Error !  Number: " & $HexNumber & "   ScriptLine: " & $oMyError.scriptline & "   Description:" & $oMyRet[1] & @LF)
    SetError(1); something to check for when this function returns
    Return
EndFunc   ;==>MyErrFunc


По сути мне нужно реализовать отправку EMAIL сообщения на за ранее указанный адрес и всё это в локальной сети. :stars:
 

DezmontDeXa

Новичок
Сообщения
23
Репутация
0
На MSDN наткнулся на такую вещь:
Код:
            // Set Proxy properties			
            oField = oFields["http://schemas.microsoft.com/cdo/configuration/urlproxyserver"];
oField.Value = "itgproxy";

            oField = oFields["http://schemas.microsoft.com/cdo/configuration/proxyserverport"];
oField.Value = 80;

Тестирую, не могу понять пашет или нет.
 

zert88

Новичок
Сообщения
14
Репутация
0
Блин, плохо, что нет реализации в рамках только autoit-а,
 
Верх