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:

  1. Sender
  2. Empfänger
  3. cc
  4. bcc
  5. Titel E-Mail
  6. Name der GuiXT Langtextvariable die den Bodytext der E-Mail beinhaltet
  7. „X“ setzen falls BodyText = HTML, falls reiner Text = “ “ setzen.
  8. SMTP Server
  9. Port
  10. Authentification (Normalerweise = 1)
  11. User
  12. Passwort
  13. 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;
}

Empfehlen