Send multiple attachments in a 163 email.

Source: Internet
Author: User

 

Send multiple attachments in a 163 email.

 


Var currFocus;
Var ExistAttaInfo = new Array ();
Var oldDelAttas = new Array ();
Var attaIdx = 0;
Var IsIE;
Function fInitMSIE (){
If (navigator. userAgent. indexOf ("MSIE ")! =-1 ){
IsIE = true;
} Else {
IsIE = false;
}
}
FInitMSIE ();



Function fTrim (str ){
Str = str. replace (/(^ \ s *)/,"");
Str = str. replace (/(\ s * $ )/,"");
Return str;
}

// This js file is used for js functions that compose.htm sends multiple attachments at the same time. It supports the IE and NNx series.
// All functions are applicable to the IE and NNx series. You can call them directly.
// The function determines the browser type based on the statement, and then adds elements based on different bowser attributes.
// The main function is to dynamically create and delete various form elements
// Written by xpr

// Function list
// Configure //-------------------------------------------------------------------------------------------------------------------
// IsIEBrowser () Return Value: true (IE) false (NNx)
// Exist (fileId) to determine whether the fileId already exists
// AddInputFile (spanId, fileId) adds the input file with the index number to the element named spanId
// Addbr (spanId, brId) adds a line break whose id is brId to the element named spanId.
// Adddel (spanId, index) adds the "delete" button with index in the element named spanId, which can delete the corresponding input file and br
// Addhidden (spanId, hiddenId, value) adds the input type with id hiddenId and value hidden to the element named spanId.
// Configure //-------------------------------------------------------------------------------------------------------------------

Var IsIE;
Var attaIdx = 0;

// Search, global variable
// Configure //-----------------------------------------------------------------------------------------------------------
Function IsIEBrowser (){
If (navigator. userAgent. indexOf ("MSIE ")! =-1 ){
Return true;
} Else {
Return false;
}
}

// Add the attachment function () to idfilespan. The base is attaIdx.

Function add (){

Addfile ("idfilespan", attaIdx );
AttaIdx ++;
Return false;
}

// ------------------------------------------ Fileexist ()----------------------------------------------------------
// Edited by alun
Function exist (fileId ){
Var file = document. getElementById (fileId );
Var result = false;
If (file! = Null ){
If (file. value! = Null & file. value! = ""){
Result = existFile (file );

} // If
}
If (result)
{
Alert ("You have added this attachment, and the new attachment will be deleted ");
// Document. sendmail. "+ fileId +". value = """;
Var attach_num = fileId. substring (10, 12 );

Delfile ("idfilespan", attach_num );

// -- AttaIdx;
// Document. getElementById ("idAttachOper" + attaIdx). click ();
}
} // End of function
// Added by alun
Function getfilename (attaName ){
Var s = attaName. lastIndexOf ('\\');
Return attaName. substr (s + 1, attaName. length-s-1 );
}
// Added by alun
Function existFile (file)
{
Var form = document. myform;
For (var I = 0; I <form. elements. length; I ++ ){
If (form. elements. type = "file" & form. elements. name! = File. name ){
If (file. value = form. elements. value ){
// Alert (form. elements. value = null );
Return true;
}
}
} //
For (var I = 0; I <EXISTATTAINFO. LENGTH ;{
Var theName = ExistAttaInfo;
If (theName! = Null & theName! = "" & TheName = getfilename (file. name )){
Return true;
}
}
Return false;
}
// ---------------------------------------- Addfile (spanId, index )----------------------------------------------
Function addfile (spanId, index)
{
Var strIndex = "" + index;

Var fileId = "attachfile" + strIndex;
Var brId = "idAttachBr" + strIndex;
AddInputFile (spanId, fileId );

Adddel (spanId, index );

Addbr (spanId, brId );
// Document. getElementById ("attachfile" + strIndex). click ();
Return;
}
// --------------------------------------------- Sub fuction addInputFile -----------------------------------------
Function addInputFile (spanId, fileId)
{
Var span = document. getElementById (spanId );
If (span! = Null ){
If (! IsIE ){
Var fileObj = document. createElement ("input ");
If (fileObj! = Null ){
FileObj. type = "file ";
FileObj. name = fileId;
FileObj. id = fileId;
FileObj. size = "50 ";
Var clickEvent = "exist ('" + fileId + "')";
FileObj. setAttribute ("onclick", clickEvent, 0 );
Span. appendChild (fileObj );
} // If fileObj
}//! IsIE

If (IsIE ){
// Var fileTag = "var fileTag =" var fileObj = document. createElement (fileTag );
Span. appendChild (fileObj );
} // IsIE if

} // If span
}

Function addbr (spanId, brId)
{
Var span = document. getElementById (spanId );
If (span! = Null ){
Var brObj = document. createElement ("br ");
If (brObj! = Null ){
BrObj. name = brId;
BrObj. id = brId;
Span. appendChild (brObj );
} // I2f
} // If
Return;
}

Function adddel (spanId, index)
{
Var strIndex = "" + index;
Var delId = "idAttachOper" + strIndex;
Var span = document. getElementById (spanId );
If (span! = Null ){
Var oTextNode = document. createElement ("SPAN ");
OTextNode. style. width = "5px ";
Span. appendChild (oTextNode );
If (IsIE ){
Var tag = "";
Var delObj = document. createElement (tag );
If (delObj! = Null ){
Span. appendChild (delObj );
} // If

} // Is IE

If (! IsIE ){
Var delObj = document. createElement ("input ");
If (delObj! = Null ){
DelObj. name = delId;
DelObj. id = delId;
DelObj. type = "button ";
Var clickEvent = "return delfile ('" + spanId + "'," + strIndex + ");";
DelObj. setAttribute ("onclick", clickEvent );
Span. appendChild (delObj );
} // If
}//! IsIE if
If (delObj! = Null) delObj. value = "delete ";
} // Main if
Return;
}


// Configure //-------------------------------------------------------------------------------------------------------------


// ----------------------------------------------- Delete input file -----------------------------------------------
Function delfile (spanId, index)
{
Var strIndex = "" + index;
Var fileId = "attachfile" + strIndex;
Var brId = "idAttachBr" + strIndex;
Var delId = "idAttachOper" + strIndex;
// First, get the element
Var span = document. getElementById (spanId );
// Alert ("del span:" + span );
If (span = null) return false;

Var fileObj = document. getElementById (fileId );
If (fileObj = null) return false;

Var brObj = document. getElementById (brId );
If (brObj = null) return false;

Var delObj = document. getElementById (delId );
// Alert ("del delId:" + delObj );
If (delObj = null) return false;

// Second, create the replace element
Var temp = document. createElement ("SPAN ");
// Third, replace it
Span. replaceChild (temp, fileObj );
Span. replaceChild (temp, brObj );
// Added by Harry, Repair Remove attached bug 2005/04/04
Span. removeChild (delObj. previussibling );
Var attach = document. getElementById ("attach ");
If (span. getElementsByTagName ("INPUT"). length = 1) attach. childNodes [0]. nodeValue = 'add attachment ';
// End
Span. replaceChild (temp, delObj );

Return false;
}

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.