Sie wollen mittels GuiXT und der calljs Funktion ein E-Mail inkl. mehreren Attachments versenden.
Der Aufruf des Scriptes erfolgt wie folgt:
calljs sendmail „par1“ „par2“ „par3“ „par4“ „par5“ „par6“ … „par13“
wobei die Parameter folgende Bedeutung haben:
- Sender
- Empfänger
- cc
- bcc
- Titel E-Mail
- Name der GuiXT Langtextvariable die den Bodytext der E-Mail beinhaltet
- „X“ setzen falls BodyText = HTML, falls reiner Text = “ “ setzen.
- SMTP Server
- Port
- Authentification (Normalerweise = 1)
- User
- Passwort
- Name der GuiXT-Langtextvariable die die einzelnen Attachments inkl. Pfad enthält
Java Script:
function sendmail(from, to, cc, bcc, sub, bodytext, html, server, port, auth, user, pass, attachment) {
var olByValue = 1;
var sAttachments, xAttachment, sAttachment;
// Attachments aus GuiXT Langtext lesen
sAttachments = guixt.GetText(attachment);
// Attachments splitten
xAttachment = sAttachments.split("\r\n");
var obj = guixt.CreateObject("CDO.Message");
var str = "http://schemas.microsoft.com/cdo/configuration/";
for (var k = 0; k < xAttachment.length; k++)
{
sAttachment = xAttachment[k];
if (sAttachment.length>0)
{
obj.AddAttachment(sAttachment);
};
};
obj.Configuration.Fields.Item(str + "sendusing") = 2;
if (typeof(server) != "undefined") {
obj.Configuration.Fields.Item(str + "smtpserver") = server;
}
if (typeof(port) != "undefined") {
obj.Configuration.Fields.Item(str + "smtpserverport") = port;
}
if (typeof(auth) != "undefined") {
obj.Configuration.Fields.Item(str + "smtpauthenticate") = auth;
}
if (typeof(user) != "undefined") {
obj.Configuration.Fields.Item(str + "sendusername") = user;
}
if (typeof(pass) != "undefined") {
obj.Configuration.Fields.Item(str + "sendpassword") = pass;
}
try {
obj.Configuration.Fields.Update();
} catch (e) {
throw e;
}
obj.From = from;
obj.To = to;
obj.Cc = cc;
obj.Bcc = bcc;
obj.Subject = sub;
if (html == "X") {
obj.HTMLBody = guixt.GetText(bodytext);
} else {
obj.TextBody = guixt.GetText(bodytext);
}
try {
obj.Send();
} catch (e) {
throw e;
}
obj = null;
}
