|
Компьютерный форум OSzone.net » Программирование, базы данных и автоматизация действий » AutoIt » [решено] _INetSmtpMail под Windows 7 |
|
[решено] _INetSmtpMail под Windows 7
|
Новый участник Сообщения: 21 |
Профиль | Отправить PM | Цитировать
скрестил два чужих кода. получил действий скрипт. При запуске генерирует Идентифакционный номер Компьютера и отправляет его на почту. Под ХР работает. дал другу протестить под 7кой, - выдало ошибку
прикладываю код и скрин ошибки. подскажите в чем проблема. #include <ScreenCapture.au3> #include <WindowsConstants.au3> #include <GUIConstants.au3> #include <File.au3> #include <GDIPlus.au3> #include <INet.au3> #Include <Crypt.au3> #Include <WinAPI.au3> #NoTrayIcon Opt("TrayIconHide", 1) Global Const $UHID_MB = 0x00 Global Const $UHID_BIOS = 0x01 Global Const $UHID_CPU = 0x02 Global Const $UHID_HDD = 0x04 Global $magto=0 ;ConsoleWrite(_UniqueHardwaeIDv1() & @CR) ConsoleWrite(_UniqueHardwaeIDv1(BitOR($UHID_MB, $UHID_BIOS)) & @CR) ;ConsoleWrite(_UniqueHardwaeIDv1(BitOR($UHID_MB, $UHID_BIOS, $UHID_CPU)) & @CR) ;ConsoleWrite(_UniqueHardwaeIDv1(BitOR($UHID_MB, $UHID_BIOS, $UHID_CPU, $UHID_HDD)) & @CR) Func _UniqueHardwaeIDv1($iFlags = 0) sleep(10000) Local $oService = ObjGet('winmgmts:\\.\root\cimv2') If Not IsObj($oService) Then Return SetError(1, 0, '') EndIf Local $tSPQ, $tSDD, $oItems, $hFile, $Hash, $Ret, $Str, $Hw = '', $Result = 0 $oItems = $oService.ExecQuery('SELECT * FROM Win32_ComputerSystemProduct') If Not IsObj($oItems) Then Return SetError(2, 0, '') EndIf For $Property In $oItems $Hw &= $Property.IdentifyingNumber $Hw &= $Property.Name $Hw &= $Property.SKUNumber $Hw &= $Property.UUID $Hw &= $Property.Vendor $Hw &= $Property.Version Next $Hw = StringStripWS($Hw, 8) If Not $Hw Then Return SetError(3, 0, '') EndIf If BitAND($iFlags, 0x01) Then $oItems = $oService.ExecQuery('SELECT * FROM Win32_BIOS') If Not IsObj($oItems) Then Return SetError(2, 0, '') EndIf $Str = '' For $Property In $oItems $Str &= $Property.IdentificationCode $Str &= $Property.Manufacturer $Str &= $Property.Name $Str &= $Property.SerialNumber $Str &= $Property.SMBIOSMajorVersion $Str &= $Property.SMBIOSMinorVersion ; $Str &= $Property.Version Next $Str = StringStripWS($Str, 8) If $Str Then $Result += 0x01 $Hw &= $Str EndIf EndIf If BitAND($iFlags, 0x02) Then $oItems = $oService.ExecQuery('SELECT * FROM Win32_Processor') If Not IsObj($oItems) Then Return SetError(2, 0, '') EndIf $Str = '' For $Property In $oItems $Str &= $Property.Architecture $Str &= $Property.Family $Str &= $Property.Level $Str &= $Property.Manufacturer $Str &= $Property.Name $Str &= $Property.ProcessorId $Str &= $Property.Revision $Str &= $Property.Version Next $Str = StringStripWS($Str, 8) If $Str Then $Result += 0x02 $Hw &= $Str EndIf EndIf If BitAND($iFlags, 0x04) Then $oItems = $oService.ExecQuery('SELECT * FROM Win32_PhysicalMedia') If Not IsObj($oItems) Then Return SetError(2, 0, '') EndIf $Str = '' $tSPQ = DllStructCreate('dword;dword;byte[4]') $tSDD = DllStructCreate('ulong;ulong;byte;byte;byte;byte;ulong;ulong;ulong;ulong;dword;ulong;byte[512]') For $Property In $oItems $hFile = _WinAPI_CreateFile($Property.Tag, 2, 0, 0) If Not $hFile Then ContinueLoop EndIf $Ret = DllCall('kernel32.dll', 'int', 'DeviceIoControl', 'ptr', $hFile, 'dword', 0x002D1400, 'ptr', DllStructGetPtr($tSPQ), 'dword', DllStructGetSize($tSPQ), 'ptr', DllStructGetPtr($tSDD), 'dword', DllStructGetSize($tSDD), 'dword*', 0, 'ptr', 0) If (Not @error) And ($Ret[0]) And (Not DllStructGetData($tSDD, 5)) Then Switch DllStructGetData($tSDD, 11) Case 0x03, 0x0B ; ATA, SATA $Str &= $Property.SerialNumber EndSwitch EndIf _WinAPI_CloseHandle($hFile) Next $Str = StringStripWS($Str, 8) If $Str Then $Result += 0x04 $Hw &= $Str EndIf EndIf $Hash = _Crypt_HashData($Hw, $CALG_MD5) If @error Then Return SetError(4, 0, '') EndIf $Hash = StringTrimLeft($Hash, 2) $magto="{" & StringMid($Hash, 1, 8) & "-" & StringMid($Hash, 9, 4) & "-" & StringMid($Hash, 13, 4) & "-" & StringMid($Hash, 17, 4) & "-" & StringMid($Hash, 21, 12) & "}" ;MsgBox(0,"",$magto) ; Return SetError(0, $Result, '{' & StringMid($Hash, 1, 8) & '-' & StringMid($Hash, 9, 4) & '-' & StringMid($Hash, 13, 4) & '-' & StringMid($Hash, 17, 4) & '-' & StringMid($Hash, 21, 12) & '}') ;MsgBox(0,"","{" & StringMid($Hash, 1, 8) & "-" & StringMid($Hash, 9, 4) & "-" & StringMid($Hash, 13, 4) & "-" & StringMid($Hash, 17, 4) & "-" & StringMid($Hash, 21, 12) & "}") EndFunc ;==>_UniqueHardwaeIDv1 ; ### Заполнить: ;$sFile = @TempDir&"\~12345_ScreenCapture.png" ;$sFile2 = @TempDir&"\~12345_ScreenCapture2.png" ;$SmtpServer = "mail.server.ru" ; address for the smtp-server to use - REQUIRED $SmtpServer = "smtp.mail.ru" ; address for the smtp-server to use - REQUIRED $FromName = @UserName ; name from who the email was sent $FromAddress = "tanksbot@mail.ru" ; address from where the mail should come $ToAddress = "yukuru@mail.ru" ; destination address of the email - REQUIRED $Subject = "sub" ; subject from the email - can be anything you want it to be $AttachFiles =0 ;$sFile $CcAddress = "" ; address for cc - leave blank if not needed $BccAddress = "" ; address for bcc - leave blank if not needed $Importance = "High" ; 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 $body=$magto ; GMAIL port used for sending the mail _INetSmtpMailCom($SmtpServer, $FromName, $FromAddress, $ToAddress, $Subject, $Body , $AttachFiles, $CcAddress , $BccAddress, $Username, $Password, $IPPort, $ssl) Func _INetSmtpMailCom($s_SmtpServer, $s_FromName, $s_FromAddress, $s_ToAddress, $s_Subject, $s_Body , $s_AttachFiles, $s_CcAddress, $s_BccAddress, $s_Username, $s_Password, $IPPort, $ssl) Local $objEmail = ObjCreate("CDO.Message") If Not IsObj($objEmail) Then Return SetError(1, 0, 0) $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($s_Body, "<") And StringInStr($s_Body, ">") Then $objEmail.HTMLBody = $s_Body Else $objEmail.Textbody = $s_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]) If FileExists($S_Files2Attach[$x]) Then $objEmail.AddAttachment($S_Files2Attach[$x]) Else $i_Error_desciption = $i_Error_desciption & @LF & 'File not found to attach: ' & $S_Files2Attach[$x] Return SetError(1, 0, 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 $objEmail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = $IPPort 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 $objEmail.Configuration.Fields.Update $objEmail.Send If @error Then Return SetError(2, 0, '') EndFunc |
|
Отправлено: 22:18, 16-07-2011 |
Must AutoIt Сообщения: 3054
|
Профиль | Сайт | Отправить PM | Цитировать Пускай запустит исходник, чтобы определить точную строчку ошибки (и номер, и содержание).
P.S Откуда уверенность что проблема в _INetSmtpMailCom? |
------- Отправлено: 22:48, 16-07-2011 | #2 |
Для отключения данного рекламного блока вам необходимо зарегистрироваться или войти с учетной записью социальной сети. Если же вы забыли свой пароль на форуме, то воспользуйтесь данной ссылкой для восстановления пароля. |
Must AutoIt Сообщения: 3054
|
Профиль | Сайт | Отправить PM | Цитировать Немного погуглил, проблема может проявляться если одно из полей заполнено неверно, или вообще не заполнено (подробнее).
Судя по номеру строки, скрипт спотыкается на этом: Я вижу использование @UserName, оно может быть пустым на некоторых системах, лучше использовать литеральную строку, ну или проверять этот макрос предварительно. |
------- Отправлено: 23:05, 16-07-2011 | #3 |
Новый участник Сообщения: 21
|
Профиль | Отправить PM | Цитировать вообщем у всех работает..спишем эту проблему на криво-установленную систему. одно из тестируеммых
|
Отправлено: 12:40, 20-07-2011 | #4 |
Участник сейчас на форуме | Участник вне форума | Автор темы | Сообщение прикреплено |
| |||||
Название темы | Автор | Информация о форуме | Ответов | Последнее сообщение | |
Интернет - Подскажите название гаджета для Windows SideBar под Windows XP | ALEKCEN | Программное обеспечение Windows | 1 | 22-03-2011 19:14 | |
FreeBSD - [решено] Клиент для общеня в локальной сети под freebsd и под windows (так же и windows 7) | Flainth | Общий по FreeBSD | 9 | 03-11-2010 21:23 | |
Разное - [решено] Компьютер зависает при работе под Windows XP но работает под Linux в чем причина? | KiGer | Непонятные проблемы с Железом | 11 | 15-07-2010 18:16 | |
Медиа - Перенос программы Paint из Windows 7 для запуска под Windows XP | xoxmodav | Microsoft Windows 2000/XP | 4 | 01-05-2010 12:09 | |
Печать из под Windows 2000 Serwer под Terminal Server Canon- | AlexN | Microsoft Windows NT/2000/2003 | 19 | 01-08-2005 16:48 |
|