<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[Серый форум &mdash; AHK: Отправка логов]]></title>
	<link rel="self" href="https://forum.script-coding.com/extern.php?action=feed&amp;tid=16848&amp;type=atom" />
	<updated>2022-01-01T04:17:12Z</updated>
	<generator>PunBB</generator>
	<id>https://forum.script-coding.com/viewtopic.php?id=16848</id>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Отправка логов]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=151465#p151465" />
			<content type="html"><![CDATA[<div class="quotebox"><cite>yakmuve пишет:</cite><blockquote><p>Здравствуйте, как можно сделать, чтоб программа отправляла из EditBox сообщение на почту.</p></blockquote></div><div class="codebox"><pre><code>pmsg 			:= ComObjCreate(&quot;CDO.Message&quot;)
pmsg.From 		:= &quot;&quot;&quot;AHKUser&quot;&quot; &lt;ahk.com&gt;&quot;
pmsg.To 		:= &quot;ahk.com&quot;
pmsg.BCC 		:= &quot;&quot;   ; Blind Carbon Copy, Invisable for all, same syntax as CC
;pmsg.CC 		:= &quot;ahk, Other-ahk&quot;
;pmsg.CC 		:= &quot;Somebody@somewhere.com, Other-somebody@somewhere.com&quot;
pmsg.Subject 	:= &quot;Name.&quot;

;You can use either Text or HTML body like
pmsg.TextBody 	:= &quot;Name&quot;
;OR
;pmsg.HtmlBody := &quot;&lt;html&gt;&lt;head&gt;&lt;title&gt;Hello&lt;/title&gt;&lt;/head&gt;&lt;body&gt;&lt;h2&gt;Hello&lt;/h2&gt;&lt;p&gt;Testing!&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;&quot;
fields.sendusername := &quot;lolin@gmail.com&quot;
fields.sendpassword := &quot;passwod&quot;



sAttach   		:= &quot;C:\Users\Home\Desktop\test.jpg&quot; ; can add multiple attachments, the delimiter is |

fields := Object()
fields.smtpserver   := &quot;smtp.gmail.com&quot; ; specify your SMTP server
fields.smtpserverport     := 465 ; 25
fields.smtpusessl      := True ; False
fields.sendusing     := 2   ; cdoSendUsingPort
fields.smtpauthenticate     := 1   ; cdoBasic
fields.sendusername := &quot;Somebody@somewhere.com&quot;
fields.sendpassword := &quot;password&quot;
fields.smtpconnectiontimeout := 60
schema := &quot;http://schemas.microsoft.com/cdo/configuration/&quot;
pfld :=   pmsg.Configuration.Fields

For field,value in fields
	pfld.Item(schema . field) := value
pfld.Update()

Loop, Parse, sAttach, |, %A_Space%%A_Tab%
  pmsg.AddAttachment(A_LoopField)
</code></pre></div><p>В настрайках аккаунта нужно разрешить доступ для ненадежных приложений. https://myaccount.google.com/lesssecureapps.&nbsp; Эта опция недоступна в аккаунтах с двухэтапной аутентификацией. Для gmail.com.</p><div class="codebox"><pre><code>pmsg.HtmlBodyPart.Charset := &quot;utf-8&quot;</code></pre></div><p> Если в сообщении кириллица не правильно отображается.</p>]]></content>
			<author>
				<name><![CDATA[EV]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=40256</uri>
			</author>
			<updated>2022-01-01T04:17:12Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=151465#p151465</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Отправка логов]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=151462#p151462" />
			<content type="html"><![CDATA[<p><strong>teadrinker</strong>, да все верно. Можно любой хостинг с php.</p>]]></content>
			<author>
				<name><![CDATA[andrey.a.polyakov.b2c]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=42228</uri>
			</author>
			<updated>2021-12-31T21:56:06Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=151462#p151462</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Отправка логов]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=151401#p151401" />
			<content type="html"><![CDATA[<p><strong>andrey.a.polyakov.b2c</strong>, правильно я понимаю, что решение предполагает наличие своего сайта либо локального сервера?</p>]]></content>
			<author>
				<name><![CDATA[teadrinker]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=24515</uri>
			</author>
			<updated>2021-12-25T19:54:39Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=151401#p151401</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Отправка логов]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=151400#p151400" />
			<content type="html"><![CDATA[<p><strong>yakmuve</strong>, проще написать скрипт на php и уже к нему обращаясь отправлять почту, например:<br /></p><div class="codebox"><pre><code>
&lt;?php
$to = $_GET[&#039;mail&#039;];
$headers = array(
    &#039;From&#039; =&gt; &#039;Мой_Софт&lt;soft@my.ru&gt;&#039;,
    &#039;X-Mailer&#039; =&gt; &#039;PHP/&#039; . phpversion()
);
$subject = $_GET[&#039;t&#039;];
$message = $_GET[&#039;m&#039;];

mail($to,$subject,$message,$headers);
?&gt;
</code></pre></div><p>Ну и в Ahk отправляем запрос например на F2:<br /></p><div class="codebox"><pre><code>
global WinHttpRequestOption_EnableRedirects := 6
global WinHttpRequestOption_MaxAutomaticRedirects := 14
global WinHttpRequestOption_EnableHttpsToHttpRedirects := 12
global oHttpRequest := ComObjCreate(&quot;WinHttp.WinHttpRequest.5.1&quot;)
oHttpRequest.Option(WinHttpRequestOption_EnableRedirects) := -1
oHttpRequest.Option(WinHttpRequestOption_EnableHttpsToHttpRedirects) := -1
oHttpRequest.Option(WinHttpRequestOption_MaxAutomaticRedirects) := 20
global HttpObj := ComObjCreate(&quot;WinHttp.WinHttpRequest.5.1&quot;)
global oHttpRequest := ComObjCreate(&quot;WinHttp.WinHttpRequest.5.1&quot;)

F2::
    SendMail(&quot;Тестовая тема&quot;,&quot;Тестовое сообщение&quot;,&quot;mmm@yandex.ru&quot;)
Return

SendMail(subject,message,mail ) {
    try
    {
        oHtmlDoc := documentFromURL(&quot;http://сайт/mail.php?t=&quot; . subject . &quot;&amp;m=&quot; . message . &quot;&amp;mail=&quot; . mail)
        return,&quot;Письмо отправлено&quot;
    }
    catch e {
        return,&quot;Ошибка сервера &quot; . e.message
    }
}

GetHTML(ByRef sHTMLCode, ByRef sBaseURL) {
    oDoc := ComObjCreate(&quot;htmlfile&quot;)
    oDoc.open()
    oDoc.write(&quot;&lt;base href=&quot;&quot;&quot; . sBaseURL . &quot;&quot;&quot;&gt;&quot;)
    oDoc.close()
    oDoc.body.innerHTML := sHTMLCode
return oDoc
}
documentFromURL(ByRef sURL) {
    oHttpRequest.open(&quot;GET&quot;, sURL, false)
    oHttpRequest.SetRequestHeader(&quot;User-Agent&quot;, &quot;Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; WOW64; Trident/5.0)&quot;)
    oHttpRequest.SetRequestHeader(&quot;Referer&quot;, sURL)
    oHttpRequest.SetRequestHeader(&quot;Content-Type&quot;, &quot;text/html&quot;)
    oHttpRequest.send()
return GetHTML(oHttpRequest.responseText, sURL)
}
</code></pre></div>]]></content>
			<author>
				<name><![CDATA[andrey.a.polyakov.b2c]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=42228</uri>
			</author>
			<updated>2021-12-25T13:00:46Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=151400#p151400</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Отправка логов]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=151394#p151394" />
			<content type="html"><![CDATA[<div class="quotebox"><cite>ypppu пишет:</cite><blockquote><p>По-моему не умеет AutoHotkey напрямую работать с почтой.</p></blockquote></div><p>Если чуток подзапариться, то умеет. <img src="//forum.script-coding.com/img/smilies/wink.png" width="15" height="15" /><br /><a href="http://forum.script-coding.com/viewtopic.php?id=16339">http://forum.script-coding.com/viewtopic.php?id=16339</a></p>]]></content>
			<author>
				<name><![CDATA[Malcev]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=26930</uri>
			</author>
			<updated>2021-12-24T21:34:45Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=151394#p151394</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Отправка логов]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=151393#p151393" />
			<content type="html"><![CDATA[<p><strong>teadrinker</strong>, спасибо за ориентир, буду искать документацию касательно данных функций.</p>]]></content>
			<author>
				<name><![CDATA[yakmuve]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=42183</uri>
			</author>
			<updated>2021-12-24T21:13:02Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=151393#p151393</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Отправка логов]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=151388#p151388" />
			<content type="html"><![CDATA[<p>AHK умет работать с COM-объектами, например, с CDO.Message.</p>]]></content>
			<author>
				<name><![CDATA[teadrinker]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=24515</uri>
			</author>
			<updated>2021-12-24T19:45:45Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=151388#p151388</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Отправка логов]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=151386#p151386" />
			<content type="html"><![CDATA[<p>По-моему не умеет AutoHotkey напрямую работать с почтой. Ищите какие-нибудь программы-посредники, поддерживающие автоматизацию. На форуме <a href="https://autohotkey.com">https://autohotkey.com</a> много чего есть, наверное там уже поднимался такой вопрос.</p>]]></content>
			<author>
				<name><![CDATA[ypppu]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=5974</uri>
			</author>
			<updated>2021-12-24T19:16:50Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=151386#p151386</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[AHK: Отправка логов]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=151382#p151382" />
			<content type="html"><![CDATA[<p>Здравствуйте, как можно сделать, чтоб программа отправляла из EditBox сообщение на почту.</p>]]></content>
			<author>
				<name><![CDATA[yakmuve]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=42183</uri>
			</author>
			<updated>2021-12-24T18:38:39Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=151382#p151382</id>
		</entry>
</feed>
