// SENDMAIL.VDM -- E-mail the active file or block. // // CZ-modification-begin // // Asks user for key fields "to" and "subject". // The "From" field is preset with the default config_string "MailFrom". // MAIL_Return_Address ! // The "server" field is likewise set from "Mail_Server" // and "Reply-to" is set from "Mail_Reply_To". // The "from", "server" and "reply-to" strings may be optionally // saved into VEDIT.INI: // // MAIL_SERVER "xxx.yyy.zzz" // MAIL_RETURN_ADDRESS "name@server.dd" // MAIL_REAL_NAME "firstname lastname" // MAIL_REPLY_TO "" // // Example: // // MAIL_SERVER "lxz1.tkesbo01.com" // MAIL_RETURN_ADDRESS "chriS@lxz1" // Must be xxx@yyy, otherwise *BREAK* // MAIL_REAL_NAME "Christian Ziemski" // Not yet sent? // MAIL_REPLY_TO "" // // and using a "To:" zlogsys@lxz1 // // gives a mail header like: // // strange: server part handled differently!!!! // From chriS@lxz1.tkesbo01.com Wed Oct 1 09:11:07 2003 // server part automagically completed if necessary // Date: Wed, 1 Oct 2003 09:11:07 +0200 // From: chriS@tks-es.thyssenkrupp.com // server part autom. filled with system default!? Can't be changed by user // To: zlogsys@lxz1.tkesbo01.com // server part automagically completed if necessary // Subject: Test44 // // // second example: // // MAIL_SERVER "lxz1.tkesbo01.com" // MAIL_RETURN_ADDRESS "chriS@x" // MAIL_REAL_NAME "Christian Ziemski" // MAIL_REPLY_TO "" // // From chriS@x Wed Oct 1 09:32:10 2003 // here the server part remains "x" ?!?!??! // Date: Wed, 1 Oct 2003 09:32:10 +0200 // From: chriS@x // To: zlogsys@lxz1.tkesbo01.com // Subject: Test 88 // // // CZ-end // Implements {File, SendMail}. // // Originally by: Greenview Data, Inc. // Last change: 22-Sep-2003 // Last change: 01-Oct-2003 CZ // // Requires: VEDIT Plus for Windows 6.0 or later. // CZ: really from 6.0 ??? // // From VEDIT: Highlight a block and select {FILE, SendMail}. // This macro will prompt for keyfields and options. // (It is unnecessary to highlight when sending the entire file). // // From OS: VPW -X SENDMAIL filename // // This will prompt for the keyfields and options and then // e-mail the entire file. It will remain in VEDIT. // // -OR- VPW -C SendMail("'server:...','From:...','To:...','Subject:...'",bpos,epos,options) filename // // Option: COLSET Send columnar block; requires additional parameters "colbeg,colend" // // #104 = Beginning column for columnar block. // #105 = Ending column for columnar block. // #106 = Beginning block position. // #107 = Ending block position. // #108 = 'r' for Dialog_Input_1(). // /////////////////////////////////////////////////////////////////////////////// // // Ensure this is the Windows/NT version and the version # >= 6.0 // #105 = 0 if (OS_Type==1 && Is_Win32_Version) { if (Version_Num >= 600) { #105=1 } } if (#105==0){ Message("\n****Can only be run by the 32-bit Windows version 6.0 or later.") Type_Newline() Break_Out(EXTRA+CONFIRM) } // // Ensure there is actually something to send. // if (File_Size==0){ Alert() Get_Key("Nothing to send!",STATLINE) if (Is_Auto_Execution && Macro_Num==100){ Qally() }else{ Break_Out(EXTRA) } } ////////////////////////////////////////////////// // // // Initialize for Dialog_Input_1() // // // ////////////////////////////////////////////////// // // Determine beginning and ending block positions #106 and #107. // if (!Column_Mode) { // When no colum markers.... // // Determine block begin/end positions. // Set #106 = block_begin ? block_begin : 0. // if ((#106=Block_Begin)==-1){ // When no defined block markers... #106++ // Set #106 = 0 #107 = File_Size // Set #107 = File_Size // // Else at least one marker set. // Set #107 = block_end ? block_end : Cur_Pos. // } else { if ((#107=Block_End)==-1) { // When (#107 = block_end) is undefined... If (!At_BOL) { Line(1,NOERR) } #107 = Cur_Pos // Use edit position }} // // For columnar blocks, use defined parameters. // } else { #104=Column_Begin #105=Column_End #106=Block_Begin if ((#107=Block_End)==-1){ #105 = Cur_Col #107 = Cur_Pos } #102=Config(S_DSP_MODE) if (#102&8){ // hex #104 = ((#104-1)/3)+1 #105 = ((#105-1)/3)+1 } if (#102&16){ // octal #104 = ((#104-1)/4)+1 #105 = ((#105-1)/4)+1 } if (#102&32){ // bit-wise #104 = ((#104-1)/9)+1 #105 = ((#105-1)/9)+1 } // // Increment end position for 1-column columnar blocks at BOL. // Final line doesn't get sent otherwise. // if ( #104 == 1 && #105 == 1 && #107 < File_Size ) { #107++ } // // Normalize the columns #104 < #105. // if (#104>#105){ #103=#104 #104=#105 #105=#103 } } // // Normalize the file positions #106 < #107. // if (#106>#107){ #103=#106 #106=#107 #107=#103 } // // Set #108 = 'r' for Dialog_Input_1(). // Initialize numeric registers 'r' through 'r'+8 to zero. // (Only using one, currently). // #10 = 9 // Maximum # strings #11 = 4 // # SendMail edit boxes #12 = 4 // # SendMail Configuration edit boxes #108=13 // Thirteen is next available numreg Num_Push(#108,#108+#10-1) Reg_Push(#108,#108+(2*#10)-2) Reg_Set(0+#108+#10,"To:") // Edit edit boxes (SendMail) Reg_Set(1+#108+#10,"Subject:") Reg_Set(2+#108+#10,"Cc:") Reg_Set(3+#108+#10,"Bcc:") Reg_Set(4+#108+#10,"Real name:") // Edit boxes (SendMail Configuration) Reg_Set(5+#108+#10,"Return address:") Reg_Set(6+#108+#10,"Server:") Reg_Set(7+#108+#10,"Reply-to:") Reg_Set(8+#108+#10,"From:") // Static string only (SendMail) for (#100=#108;#100<#108+#10;#100++){ // Reset all options #@100=0 } // // Bring up the SendMail Configuration dialog if either // "return address" or "server" undefined. // Reg_Set(5+#108,MailReturnAddress) Reg_Set(6+#108,MailServer) if ( Reg_Size(5+#108)==0 || Reg_Size(6+#108)==0 ) { call("CONFIGURE") } ////////////////////////////////////////////////// // // // Prompt // // // ////////////////////////////////////////////////// Repeat(ALL) { // // Initialize numeric registers 'r' upto 'r'+#10, exclusive, // for check box input. (Currently only one). // Options: [] File // // // Set unchangeable File option if no block markers defined. // if (Block_Begin==-1){ // Block markers defined? #109=#108 // No, #109 refers to File option #@109=1+0x80 // Set [x] File and make unchangeable } // // Initialize From: and Reply-to: strings. // // From: // T-Reg[8] = [Full Name ] [<]MailReturnAddress[>] // Reg_Set(8+#108,MailRealName) if (Reg_Size(8+#108) == 0 ) { Reg_Set(8+#108,MailReturnAddress) } else { Reg_Set(8+#108," <",APPEND) Reg_Set(8+#108,MailReturnAddress,APPEND) Reg_Set(8+#108,">",APPEND) } // // Reply-to: // T-Reg[1] = [ Name ] // (Usually null) // Reg_Set(7+#108,MailReplyTo) // // Dialog // if (Reg_Size(7+#108)==0) { #100=DI1(#108,^`SendMail`, `|@(8+#108+#10) |@(8+#108)`, `??|@(0+#108+#10)`, `??|@(1+#108+#10)`, `??|@(2+#108+#10)`, `??|@(3+#108+#10)`, `[] Send &file `, `[&Send]`,`[&Configure]`,`[Cancel]`^, APP+CENTER+SET,0,0) } else { #100=DI1(#108,^`SendMail`, `|@(8+#108+#10) |@(8+#108)`, `|@(7+#108+#10) |@(7+#108)`, `??|@(0+#108+#10)`, `??|@(1+#108+#10)`, `??|@(2+#108+#10)`, `??|@(3+#108+#10)`, `[] Send &file `, `[&Send]`,`[&Configure]`,`[Cancel]`^, APP+CENTER+SET,0,0) } ////////////////////////////////////////////////// // // // [Cancel] // // // ////////////////////////////////////////////////// if (#100==3 || #100==0) { if (Is_Auto_Execution && Macro_Num == 100) { Qally } else { goto DONE } } ////////////////////////////////////////////////// // // // [Send] // // // ////////////////////////////////////////////////// if (#100==1) { if ( Reg_Size(5+#108)==0 || Reg_Size(6+#108)==0 ) { #100=DI1(#108,^'Warning', 'Both the MailServer and the Return Address fields must be configured before mail can be sent.', '[&Configure]','[Cancel]'^, APP+CENTER+SET,0,0) if ( Return_Value != 1 ) { return 0 }} else { break } } ////////////////////////////////////////////////// // // // [Configure] // // // ////////////////////////////////////////////////// call("CONFIGURE") } // Input loop // // Cancel SendMail if one of Server and Return_Address // is still undefined. // if ( Reg_Size(5+#108)==0 || Reg_Size(6+#108)==0 ) { goto DONE } ////////////////////////////////////////////////// // // // Process user's selections. // // Set #110 = combined options. // // // ////////////////////////////////////////////////// // // // If [x] File, set begpos and endpos. // #109=#108 // #109 refers to File option if (#@109) { #106=0 #107=File_Size } // // If block size > 1 Meg, don't restore edit position. // #110=0 if (#107-#106<1000000) { #110 = NORESTORE } // // Combine Text Registers, quoting each register's // contents with a unique delimiter and separating // each now-quoted section with commas. // #0 = bn bs(bf(extra)) Ins_Text(.^"`'/~:.) // Final colon is used as a fence SetMarker(0,cp-1) // Keep marker from sliding // // For each text register pair (From, To, Subject) ... // for ( #3 = 0; #3 < 3; #3++ ) { // // Insert name at the end of the file // EOF() #4 = Cur_Pos Reg_Ins(#3+#108+#10) // To:, Subject:, From:, Server:, etc. Ins_Char(' ') Reg_Ins(#3+#108) // // Check each possible delimiter for uniqueness. // for ( #1 = 0; #1 < Marker(0); #1++ ){ gp(#1) // Goto next possible delimiter #2 = cc // Store in numeric register rcb(0,cp,cp+1,norestore) // And in text register gp(#4) // Goto start of section being delimited Search(@0,ERRBREAK) // Exit loop if not being used } // // Validate delimiter's uniqueness. // if (cc == #2 ) {break_out(extra)} // // Quote the section and append . // EOF() Ins_Char(#2) Ins_Char(',') Ins_Newline() gp(#4) Ins_Char(#2) } // // Copy entire string back into Text Register[#108]. // Reg_Copy_Block(#108,Marker(0)+1,File_Size-1-newline_chars) Buf_Quit(OK) Buf_Switch(#0) ////////////////////////////////////////////////// // // // SendMail // // // ////////////////////////////////////////////////// if (! Column_Mode ) { Send_Mail_Block(@(#108),#106,#107,#110) } else { Send_Mail_Block(@(#108),#106,#107,#110,#104,#105) } ////////////////////////////////////////////////// // // // Terminate // // // ////////////////////////////////////////////////// :DONE: Reg_Pop(#108,#108+(2*#10)-2) Num_Pop(#108,#108+#10-1) Key_Purge() //Purge any pending keystrokes Reg_Empty(Macro_Num,EXTRA) //Empty this macro and return Return //Just in case ////////////////////////////////////////////////// // // // Configure // // // ////////////////////////////////////////////////// :CONFIGURE: Reg_Set(4+#108,MailRealName) Reg_Set(5+#108,MailReturnAddress) Reg_Set(6+#108,MailServer) Reg_Set(7+#108,MailReplyTo) // Real Name: John Doe // Return address: jon@company.com // Mail Server: smtp.comcast.com or ddd.sss.m.n // Reply-To: name #100=DI1(#108+4,^`SendMail Configuration`, `??|@(4+#108+#10)`, `??|@(5+#108+#10)`, `??|@(6+#108+#10)`, `??|@(7+#108+#10)`, `Use "Reply-to" only when you want recipients to respond to an e-mail address that differs from the "return address"; the "return address" will still be used to return undeliverable mail.`, `[&Ok]`,`[Cancel]`^, APP+CENTER+SET,0,0) if ( Return_Value !=1 ){ // Just return 0 whether canceled by the return 0 // [Cancel] button or by the key. } Config_String( MAIL_REAL_NAME, @(4+#108)) Config_String( MAIL_RETURN_ADDRESS, @(5+#108)) Config_String( MAIL_SERVER, @(6+#108)) Config_String( MAIL_REPLY_TO, @(7+#108)) return 1