<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[Серый форум &mdash; AHK: Отправка сообщений с вложениями через CDO]]></title>
	<link rel="self" href="https://forum.script-coding.com/extern.php?action=feed&amp;tid=17059&amp;type=atom" />
	<updated>2022-04-18T09:50:28Z</updated>
	<generator>PunBB</generator>
	<id>https://forum.script-coding.com/viewtopic.php?id=17059</id>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Отправка сообщений с вложениями через CDO]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=152800#p152800" />
			<content type="html"><![CDATA[<p>По-моему, лучше utf-8.</p>]]></content>
			<author>
				<name><![CDATA[teadrinker]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=24515</uri>
			</author>
			<updated>2022-04-18T09:50:28Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=152800#p152800</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Отправка сообщений с вложениями через CDO]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=152798#p152798" />
			<content type="html"><![CDATA[<p>А не подскажите, как передать русский текст?<br />Нашел решение, нужно после &quot;objMessage := ComObjCreate(&quot;CDO.Message&quot;)&quot; добавить:<br /></p><div class="codebox"><pre><code>objMessage.BodyPart.Charset := &quot;windows-1251&quot;</code></pre></div>]]></content>
			<author>
				<name><![CDATA[Phoenixxx_Czar]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=34426</uri>
			</author>
			<updated>2022-04-18T04:57:04Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=152798#p152798</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Отправка сообщений с вложениями через CDO]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=152790#p152790" />
			<content type="html"><![CDATA[<p>Во всяком случае не с помощью объекта CDO.Message.</p>]]></content>
			<author>
				<name><![CDATA[teadrinker]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=24515</uri>
			</author>
			<updated>2022-04-14T16:25:32Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=152790#p152790</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Отправка сообщений с вложениями через CDO]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=152787#p152787" />
			<content type="html"><![CDATA[<p><strong>teadrinker</strong><br />Добрый день, а возможно ли сохранение письма в &quot;отправленных&quot;?</p>]]></content>
			<author>
				<name><![CDATA[inseption86]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=38818</uri>
			</author>
			<updated>2022-04-14T16:03:31Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=152787#p152787</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Отправка сообщений с вложениями через CDO]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=152768#p152768" />
			<content type="html"><![CDATA[<p><strong>teadrinker</strong>, благодарю, вы помогли не только мне, но и людям из 2025, которые тоже будут задаваться таким вопроса хе-хе. Спасибо вам большое!</p>]]></content>
			<author>
				<name><![CDATA[yakmuve]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=42183</uri>
			</author>
			<updated>2022-04-13T09:20:22Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=152768#p152768</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Отправка сообщений с вложениями через CDO]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=152767#p152767" />
			<content type="html"><![CDATA[<p>То же самое, вместо звёздочек своё имя пользователя.</p>]]></content>
			<author>
				<name><![CDATA[teadrinker]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=24515</uri>
			</author>
			<updated>2022-04-13T08:35:07Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=152767#p152767</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Отправка сообщений с вложениями через CDO]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=152765#p152765" />
			<content type="html"><![CDATA[<p><strong>teadrinker</strong>, хм, а что вы подставляли вместо </p><div class="codebox"><pre><code>From: &quot;&quot;&quot;AHKUser&quot;&quot; &lt;******@gmail.com&gt;&quot;</code></pre></div><p> просто может я тупой новичок что-то не туда поставил...</p>]]></content>
			<author>
				<name><![CDATA[yakmuve]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=42183</uri>
			</author>
			<updated>2022-04-13T08:24:10Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=152765#p152765</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Отправка сообщений с вложениями через CDO]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=152763#p152763" />
			<content type="html"><![CDATA[<p>Не знаю, у меня так работает:<br /></p><div class="codebox"><pre><code>objMessage := ComObjCreate(&quot;CDO.Message&quot;)

Keys := { Subject: &quot;Example CDO Message&quot;
        , From: &quot;&quot;&quot;AHKUser&quot;&quot; &lt;******@gmail.com&gt;&quot;
        , To: &quot;******@mail.ru&quot;
        , Subject: &quot;hi&quot;
        , HTMLBody: &quot;&lt;p style=&quot;&quot;color: #004488; font-size: 15pt; font-family: Calibri,Verdana&quot;&quot;&gt;&quot;  ; или TextBody 
                  . &quot;Первая строка сообщения&lt;br&gt;Вторая строка сообщения&lt;/p&gt;&quot; }

for key, value in Keys
   objMessage[key] := value

objMessage.AddAttachment(&quot;D:\Downloads\Иконки\AutoHotKey Logo (Medium).ico&quot;)

namespace := &quot;http://schemas.microsoft.com/cdo/configuration/&quot;
Fields := { sendusing: 2
          , smtpserver: &quot;smtp.gmail.com&quot;
          , smtpauthenticate: 1
          , sendusername: &quot;******@gmail.com&quot;
          , sendpassword: &quot;****************&quot; ; пароль приложения https://support.google.com/accounts/answer/185833?hl=ru&amp;ref_topic=7189145
          , smtpusessl: 1
          , smtpconnectiontimeout: 60
          , smtpserverport: 465 }

for field, value in Fields
   objMessage.Configuration.Fields.Item(namespace . field) := value
   
objMessage.Configuration.Fields.Update
objMessage.Send</code></pre></div><p>Проверял на Windows 7 и 10.</p>]]></content>
			<author>
				<name><![CDATA[teadrinker]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=24515</uri>
			</author>
			<updated>2022-04-13T08:20:37Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=152763#p152763</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Отправка сообщений с вложениями через CDO]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=152758#p152758" />
			<content type="html"><![CDATA[<p><strong>teadrinker</strong> Хм, сделал пароль приложения (Windows, ToMail (написал название ahk без указания расширения) и на выходе получил 16-ти значный пароль) и вставил его в код на место пароля, </p><div class="codebox"><pre><code>fields.sendusername := &quot;123456789@gmail.com&quot;
fields.sendpassword := &quot;****************&quot;</code></pre></div><p>однако ошибка осталась. Может быть я как-то некорректно указал имя пользователя или пароль?</p>]]></content>
			<author>
				<name><![CDATA[yakmuve]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=42183</uri>
			</author>
			<updated>2022-04-13T05:50:48Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=152758#p152758</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Отправка сообщений с вложениями через CDO]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=152757#p152757" />
			<content type="html"><![CDATA[<p>Возможно, нужно ввести <a href="https://support.google.com/accounts/answer/185833?hl=ru&amp;ref_topic=7189145">пароль приложения</a> (а не пароль аккаунта). Порт 465.</p>]]></content>
			<author>
				<name><![CDATA[teadrinker]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=24515</uri>
			</author>
			<updated>2022-04-12T23:13:10Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=152757#p152757</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[AHK: Отправка сообщений с вложениями через CDO]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=152756#p152756" />
			<content type="html"><![CDATA[<p>Здравствуйте, понадобилась автоматизация данного процесса. Изучив просторы интернета нашёл такой код (аж из 2014):<br /></p><div class="codebox"><pre><code>pmsg 			:= ComObjCreate(&quot;CDO.Message&quot;)
pmsg.From 		:= &quot;&quot;&quot;AHKUser&quot;&quot; &lt;...@gmail.com&gt;&quot;
pmsg.To 		:= &quot;anybody@somewhere.com&quot;
pmsg.BCC 		:= &quot;&quot;   ; Blind Carbon Copy, Invisable for all, same syntax as CC
pmsg.CC 		:= &quot;Somebody@somewhere.com, Other-somebody@somewhere.com&quot;
pmsg.Subject 	:= &quot;Message_Subject&quot;

;You can use either Text or HTML body like
pmsg.TextBody 	:= &quot;Message_Body&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;


sAttach   		:= &quot;Path_Of_Attachment&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;...@gmail.com&quot;
fields.sendpassword := &quot;your_password_here&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)
pmsg.Send()</code></pre></div><p>Все данные у себя я заполнил/изменил. Номер порта выставил 25. После &quot;таймаута&quot; выходит ошибка 0x80040213.<br />Error: 0x80040213<br />Source: CDO.Message.1<br />Description: Транспорту не удалось подключиться к серверу.<br />HelpFile: (null)<br />HelpContext: 0<br />Specifically: Send</p><p>---&gt; pmsg.Send()</p><p>Прошу вас о помощи, либо задачка сложная, либо я тупой (скорее второе).</p>]]></content>
			<author>
				<name><![CDATA[yakmuve]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=42183</uri>
			</author>
			<updated>2022-04-12T20:26:42Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=152756#p152756</id>
		</entry>
</feed>
