Code: Select all
FileSelectFile, MyFiles, M3, %A_MyDocuments%, Select File
If SendMail(E-MailAdresse, Betreff, "Text", MyFiles)
{
Return
}
; this is a function to send emails with outlook. I only formatted it as a function, the original code isn't mine.
SendMail(ToAddress, MessageSubject, MessageBody, AttachmentPath="") {
ol := ComObjCreate("Outlook.Application")
ns := ol.getNamespace("MAPI")
ns.logon("","",true,false) ;get default MAPI profile
newMail := ol.CreateItem(0) ;0 is Outlook constant 'olMailItem' (thanks Sinkfaze)
newMail.Subject := MessageSubject
newMail.Body := MessageBody
If StrLen (AttachmentPath)
{
MessageAttach := newMail.Attachments
Loop, Parse, AttachmentPath, `n, %A_Space%%A_Tab%
{
If A_Index = 1
Root := A_LoopField
Else
MessageAttach.Add(Root . "\" . A_LoopField)
}
}
; validate the recipient, just in case...
myRecipient := ns.CreateRecipient(ToAddress)
myRecipient.Resolve
If Not myRecipient.Resolved
MsgBox, unknown recipient
Else
{
newMail.Recipients.Add(myRecipient)
;newMail.Sender := FromAddress ;this would be the from field but does not work yet
newMail.Display
}
}
ich habe im Netz dieses Code-Schnippsel gefunden. leider war der Forum-Post wo ich es her habe schon deaktiviert gewesen.
Ist es irgendwie möglich, die in der 3. Zeile stehenden Variablen vorher abzufragen durch ein Gui ?
Wenn ich das ganze mit Variablen versuche und %EMail% reinschreibe, bekomme ich die Rückmeldung, dass die E-Mail ungültig ist... (Ich vermute einfach mal, weil die Variablen in " " stehen müssen...
Das ist ja aber mit Variablen nicht möglich, da das ganze dann als Text und nicht als Variable gewertet wird oder ?
Vielen Dank für eure Hilfe.
lg Michelle