Direkter E-Mail-Versand ohne externe Software Topic is solved

Stelle Fragen zur Programmierung mit Autohotkey

Moderator: jNizM

KHA
Posts: 403
Joined: 21 Aug 2018, 11:11

Direkter E-Mail-Versand ohne externe Software

20 Oct 2019, 07:43

Guten Tag,
gibt es eine Möglichkeit per AHK ohne externe Software, ein E-mail zu verschicken?
LG
Ahk_fan
Posts: 237
Joined: 31 Aug 2018, 14:34
Contact:

Re: Direkter E-Mail-Versand ohne externe Software  Topic is solved

22 Oct 2019, 13:32

Hallo,

du kannst auch die CDO-Api nutzen.

Code: Select all

Emfa = "[email protected]"
path := "C:\Users\abc\Desktop\123.png"          ; Pfad+Dateiname Anhang
		pmsg 							:= ComObjCreate("CDO.Message")
		pmsg.From 						:= "[email protected]"
		pmsg.To 						:= Emfa
		pmsg.BCC 						:= ""   									; Blind Carbon Copy, Invisible for all, same syntax as CC
		;pmsg.CC 						:= ""										; [email protected], [email protected]
		pmsg.Subject 					:= "Test"
		;pmsg.TextBody 					:= ""
		pmsg.HtmlBody 					:= "<HTML><H2>Meldung!!!!</H2><BODY>Maschine:"

		sAttach   						:= path								; can add multiple attachments, the delimiter is |
		fields 							:= Object()

		fields.smtpserver   					:= "smtp.absender.de" 							; specify your SMTP server
		fields.smtpserverport   				:= 25									; 25
		fields.smtpusessl      					:= False									; False
		fields.sendusing     					:= 2   									; cdoSendUsingPort
		fields.smtpauthenticate 				:= 1   									; cdoBasic
		fields.sendusername 					:= "absender"
		;fields.sendpassword 					:= "xxxxxxxx"
		fields.smtpconnectiontimeout			:= 60
		schema 								:= "http://schemas.microsoft.com/cdo/configuration/"
		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(path)
		pmsg.Send()
		
return
weitere Hilfe: gogl und hier: https://support.microsoft.com/de-de/help/310212/how-to-use-the-cdosys-dll-library-to-send-an-e-mail-message-with-attac

hier gibt es noch was zur powershell-funktion:
https://www.autohotkey.com/boards/viewtopic.php?f=9&t=31817&p=148376&hilit=cdo#p148376
regards,
AHK_fan :)
https://hr-anwendungen.de
KHA
Posts: 403
Joined: 21 Aug 2018, 11:11

Re: Direkter E-Mail-Versand ohne externe Software

23 Oct 2019, 15:47

Hallo @Ahk_fan und danke für den Vorschlag.
Bekomme, immer die Meldung:
====
Error: 0x80040213 -
Source: CDO.Message.1
Description: Der Transport konnte keine Verbindung zum Server herstellen.
====
Die Zugangsdaten stimmen und Firewall ist deaktiviert.
Es ist ein Outlook-Account folgende Veränderungen habe ich vorgenommen:
fields.smtpserver := "SMTP.office365.com"
fields.smtpserverport := 587
fields.smtpusessl := True
Ahk_fan
Posts: 237
Joined: 31 Aug 2018, 14:34
Contact:

Re: Direkter E-Mail-Versand ohne externe Software

24 Oct 2019, 13:36

hmm,

ich habe es gerade mit strato, googlemail, und web.de getestet --> funktioniert

bei office365 ist es auf jeden fall "smtp.office365.com"
Port 587

hast du:

Code: Select all

	fields.sendusername 					:= "absender"
		fields.sendpassword 					:= "xxxxxxxx"
bei fields.sendpassword muss das semikolon vornedran weg und dein passwort rein. Bei Username muss evtl nur der Emailname vor dem @, oder der komplette Emailname rein inkl. @account.com....
regards,
AHK_fan :)
https://hr-anwendungen.de
Ahk_fan
Posts: 237
Joined: 31 Aug 2018, 14:34
Contact:

Re: Direkter E-Mail-Versand ohne externe Software

24 Oct 2019, 13:41

teste mal port 25 und füge noch die Zeile
fields.sendtls := True

dazwischen (vor dem .send auf jeden Fall)

das habe ich im netz gefunden(https://www.tachytelic.net/2018/12/email-vbscript-vba-office-365/):

- The account that you use must have at least an Exchange Online license.
- You will only be able to send from addresses that account has send as permission for or an alias of that account.
- It would probably be a good idea to use an account dedicated for sending SMTP because the password is being stored in clear text.
- Your Firewall or your ISPs Firewall may block outbound port 25.
- I’ve left the code for TLS in-place above but commented out, in case anyone else wants to have a play with it.
regards,
AHK_fan :)
https://hr-anwendungen.de
KHA
Posts: 403
Joined: 21 Aug 2018, 11:11

Re: Direkter E-Mail-Versand ohne externe Software

24 Oct 2019, 14:18

Danke Dir! fields.sendtls := True und port 25, damit funktioniert es mit Outlook.

Return to “Ich brauche Hilfe”

Who is online

Users browsing this forum: No registered users and 24 guests