Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.clipper.visual-objects > #4887 > unrolled thread
| Started by | baksoftgroup@gmail.com |
|---|---|
| First post | 2013-03-07 19:56 -0800 |
| Last post | 2013-03-11 13:47 -0700 |
| Articles | 5 — 3 participants |
Back to article view | Back to comp.lang.clipper.visual-objects
BLAT Wrapper (email command line EXE) baksoftgroup@gmail.com - 2013-03-07 19:56 -0800
Re: BLAT Wrapper (email command line EXE) Karl Wochele <kw@e©os-system.de> - 2013-03-08 09:25 +0100
Re: BLAT Wrapper (email command line EXE) Karl Wochele <kw@e©os-system.de> - 2013-03-08 12:00 +0100
Re: BLAT Wrapper (email command line EXE) marc3l0 <mmarloch@gmail.com> - 2013-03-08 06:28 -0800
Re: BLAT Wrapper (email command line EXE) baksoftgroup@gmail.com - 2013-03-11 13:47 -0700
| From | baksoftgroup@gmail.com |
|---|---|
| Date | 2013-03-07 19:56 -0800 |
| Subject | BLAT Wrapper (email command line EXE) |
| Message-ID | <0b1f1304-5ba4-4242-8081-980137e12c2c@googlegroups.com> |
Has anyone used BLAT from inside VO to send emails? If so, was it successful? And can you share any code? Cheers Kevin
[toc] | [next] | [standalone]
| From | Karl Wochele <kw@e©os-system.de> |
|---|---|
| Date | 2013-03-08 09:25 +0100 |
| Message-ID | <aptlj0Fct80U1@mid.individual.net> |
| In reply to | #4887 |
Hi Kevin,
I once did some tests with blat and stopped it due to the fact that I
couldn't use aliases for attachments. Here is my attempt:
CLASS BlatMail
PROTECT _CommandLine AS STRING
PROTECT _LogFile AS STRING
PROTECT AttachMents AS ARRAY
PROTECT _IsValid AS LOGIC
EXPORT Server AS STRING
EXPORT UserName AS STRING
EXPORT Password AS STRING
EXPORT FromAddress AS STRING
EXPORT FromName AS STRING
EXPORT Subject AS STRING
EXPORT DestList AS ARRAY
EXPORT CCList AS ARRAY
EXPORT BCCList AS ARRAY
EXPORT MailBody AS STRING
EXPORT BodyHTML AS STRING
EXPORT ResultString AS STRING
DECLARE ACCESS CommandLine
DECLARE ACCESS IsValid
DECLARE METHOD AddAttachment
DECLARE METHOD AddCommand
DECLARE METHOD ARRAY2List
METHOD AddAttachment(cFile AS STRING,cAlias AS STRING) AS VOID PASCAL
CLASS BlatMail
// alias doesn't work ...
AAdd(SELF:AttachMents,{cFile,cAlias})
RETURN
METHOD AddCommand(cOption AS STRING,cValue := "" AS STRING) AS VOID
PASCAL CLASS BlatMail
cOption := "-"+AllTrim(cOption)
cValue := AllTrim(cValue)
cValue := StrTran(cValue,'"','\"')
SELF:_CommandLine += cOption+" "
IF !Empty(cValue)
cValue := Ansi2Oem(cValue)
SELF:_CommandLine += '"'+cValue+'" '
ENDIF
RETURN
METHOD ARRAY2List(a AS ARRAY) AS STRING PASCAL CLASS BlatMail
LOCAL cList AS STRING
LOCAL n AS DWORD
cList := ""
FOR n := 1 UPTO ALen(a)
IF !Empty(cList)
cList += ","
ENDIF
cList += AllTrim(a[n])
NEXT n
RETURN cList
ACCESS CommandLine AS STRING PASCAL CLASS BlatMail
LOCAL n AS DWORD
LOCAL cCmd AS STRING
SELF:_CommandLine := ""
cCmd := SELF:ARRAY2List(SELF:DestList)
SELF:AddCommand("to",cCmd)
cCmd := SELF:ARRAY2List(SELF:CCList)
IF !Empty(cCmd)
SELF:AddCommand("cc",cCmd)
ENDIF
cCmd := SELF:ARRAY2List(SELF:BCCList)
IF !Empty(cCmd)
SELF:AddCommand("bcc",cCmd)
ENDIF
SELF:AddCommand("f",SELF:FromAddress)
IF !Empty(SELF:FromName)
SELF:AddCommand("i",SELF:FromName)
ENDIF
IF !Empty(SELF:Subject)
SELF:AddCommand("s",SELF:Subject)
ELSE
SELF:AddCommand("ss")
ENDIF
IF !Empty(SELF:BodyHTML)
SELF:AddCommand("body",SELF:BodyHTML)
SELF:AddCommand("html")
SELF:AddCommand("alttext",SELF:MailBody)
ELSE
SELF:AddCommand("body",SELF:MailBody)
ENDIF
SELF:AddCommand("server",SELF:Server)
IF !Empty(SELF:UserName)
SELF:AddCommand("u",SELF:UserName)
IF !Empty(SELF:Password)
SELF:AddCommand("pw",SELF:Password)
ENDIF
ENDIF
FOR n := 1 UPTO ALen(SELF:AttachMents)
SELF:AddCommand("attach",'"'+AllTrim(SELF:AttachMents[n][1])+'"')
NEXT n
// Use a logfile ?
// SELF:_LogFile := TempFile()
// SELF:AddCommand("log",SELF:_LogFile)
SELF:AddCommand("noh2")
SELF:AddCommand("charset","iso-8859-1")
RETURN SELF:_CommandLine
METHOD Init() CLASS BlatMail
LOCAL hLib AS PTR
IF hFunc = NULL_PTR
hLib := LoadLibrary(PSZ("Blat.dll"))
IF hLib <> NULL_PTR
hFunc := GetProcAddress(hLib,PSZ("Send"))
ENDIF
ENDIF
IF hFunc <> NULL_PTR
SELF:_IsValid := TRUE
ENDIF
SELF:DestList := {}
SELF:CCList := {}
SELF:BCCList := {}
SELF:AttachMents := {}
RETURN SELF
ACCESS IsValid AS LOGIC PASCAL CLASS BlatMail
RETURN SELF:_IsValid
METHOD Send() CLASS BlatMail
LOCAL nResult AS INT
LOCAL cCmd AS STRING
LOCAL pCmd AS PSZ
cCmd := SELF:CommandLine
// TextBox{,"Cmd",cCmd,BUTTONOKAY}:Show()
IF !Empty(SELF:_LogFile)
FErase(SELF:_LogFile)
ENDIF
pCmd := StringAlloc(cCmd)
nResult := INT(_CAST,PCALL(hFunc,pCmd))
MemFree(pCmd)
IF !Empty(SELF:_LogFile)
SELF:ResultString := MemoRead(SELF:_LogFile)
FErase(SELF:_LogFile)
ELSE
SELF:ResultString := ""
ENDIF
RETURN nResult
STATIC GLOBAL hFunc AS PTR
FUNCTION TestBlatMail() AS LOGIC
LOCAL nResult AS INT
LOCAL oMail AS BlatMail
oMail := BlatMail{}
IF oMail:IsValid
oMail:Server := "xxx.yyy.zzz.a"
oMail:FromAddress := "info@xxx.de"
oMail:DestList := {"aa@bbb.de"}
oMail:Subject := 'Testmail mit "Blat.DLL"'
oMail:MailBody := "testmail"+CRLF+'Nummer
"1"'+CHR(9)+'"XXXXXXX"'+CRLF+CRLF+"Ende"
oMail:AddAttachment("C:\test.pdf","order.pdf")
nResult := oMail:Send()
IF nResult <> 0
InfoBox{,,NTrim(nResult)+CRLF+oMail:ResultString}:Show()
ENDIF
ELSE
InfoBox{,"Fehler","BlatMail kann nicht initialisiert werden"}:Show()
ENDIF
RETURN (nResult=0)
HTH
Karl
Am 08.03.2013 04:56, schrieb baksoftgroup@gmail.com:
> Has anyone used BLAT from inside VO to send emails?
> If so, was it successful? And can you share any code?
> Cheers
> Kevin
>
[toc] | [prev] | [next] | [standalone]
| From | Karl Wochele <kw@e©os-system.de> |
|---|---|
| Date | 2013-03-08 12:00 +0100 |
| Message-ID | <aptulrFetkkU1@mid.individual.net> |
| In reply to | #4888 |
forgot to mention that you can use blat.dll and don't need blat.exe...
Karl
Am 08.03.2013 09:25, schrieb Karl Wochele:
> Hi Kevin,
>
> I once did some tests with blat and stopped it due to the fact that I
> couldn't use aliases for attachments. Here is my attempt:
>
> CLASS BlatMail
> PROTECT _CommandLine AS STRING
> PROTECT _LogFile AS STRING
> PROTECT AttachMents AS ARRAY
>
> PROTECT _IsValid AS LOGIC
>
> EXPORT Server AS STRING
> EXPORT UserName AS STRING
> EXPORT Password AS STRING
>
> EXPORT FromAddress AS STRING
> EXPORT FromName AS STRING
> EXPORT Subject AS STRING
> EXPORT DestList AS ARRAY
> EXPORT CCList AS ARRAY
> EXPORT BCCList AS ARRAY
>
> EXPORT MailBody AS STRING
> EXPORT BodyHTML AS STRING
> EXPORT ResultString AS STRING
>
> DECLARE ACCESS CommandLine
> DECLARE ACCESS IsValid
>
> DECLARE METHOD AddAttachment
> DECLARE METHOD AddCommand
> DECLARE METHOD ARRAY2List
> METHOD AddAttachment(cFile AS STRING,cAlias AS STRING) AS VOID PASCAL
> CLASS BlatMail
>
> // alias doesn't work ...
> AAdd(SELF:AttachMents,{cFile,cAlias})
>
> RETURN
>
> METHOD AddCommand(cOption AS STRING,cValue := "" AS STRING) AS VOID
> PASCAL CLASS BlatMail
>
> cOption := "-"+AllTrim(cOption)
>
> cValue := AllTrim(cValue)
> cValue := StrTran(cValue,'"','\"')
> SELF:_CommandLine += cOption+" "
> IF !Empty(cValue)
> cValue := Ansi2Oem(cValue)
> SELF:_CommandLine += '"'+cValue+'" '
> ENDIF
>
> RETURN
>
> METHOD ARRAY2List(a AS ARRAY) AS STRING PASCAL CLASS BlatMail
> LOCAL cList AS STRING
> LOCAL n AS DWORD
>
> cList := ""
> FOR n := 1 UPTO ALen(a)
> IF !Empty(cList)
> cList += ","
> ENDIF
> cList += AllTrim(a[n])
> NEXT n
>
> RETURN cList
> ACCESS CommandLine AS STRING PASCAL CLASS BlatMail
> LOCAL n AS DWORD
> LOCAL cCmd AS STRING
>
> SELF:_CommandLine := ""
>
> cCmd := SELF:ARRAY2List(SELF:DestList)
> SELF:AddCommand("to",cCmd)
>
> cCmd := SELF:ARRAY2List(SELF:CCList)
> IF !Empty(cCmd)
> SELF:AddCommand("cc",cCmd)
> ENDIF
>
> cCmd := SELF:ARRAY2List(SELF:BCCList)
> IF !Empty(cCmd)
> SELF:AddCommand("bcc",cCmd)
> ENDIF
>
> SELF:AddCommand("f",SELF:FromAddress)
> IF !Empty(SELF:FromName)
> SELF:AddCommand("i",SELF:FromName)
> ENDIF
> IF !Empty(SELF:Subject)
> SELF:AddCommand("s",SELF:Subject)
> ELSE
> SELF:AddCommand("ss")
> ENDIF
> IF !Empty(SELF:BodyHTML)
> SELF:AddCommand("body",SELF:BodyHTML)
> SELF:AddCommand("html")
> SELF:AddCommand("alttext",SELF:MailBody)
> ELSE
> SELF:AddCommand("body",SELF:MailBody)
> ENDIF
>
>
> SELF:AddCommand("server",SELF:Server)
> IF !Empty(SELF:UserName)
> SELF:AddCommand("u",SELF:UserName)
> IF !Empty(SELF:Password)
> SELF:AddCommand("pw",SELF:Password)
> ENDIF
> ENDIF
>
> FOR n := 1 UPTO ALen(SELF:AttachMents)
> SELF:AddCommand("attach",'"'+AllTrim(SELF:AttachMents[n][1])+'"')
> NEXT n
>
>
> // Use a logfile ?
> // SELF:_LogFile := TempFile()
> // SELF:AddCommand("log",SELF:_LogFile)
>
> SELF:AddCommand("noh2")
>
>
> SELF:AddCommand("charset","iso-8859-1")
>
> RETURN SELF:_CommandLine
>
> METHOD Init() CLASS BlatMail
> LOCAL hLib AS PTR
>
> IF hFunc = NULL_PTR
> hLib := LoadLibrary(PSZ("Blat.dll"))
> IF hLib <> NULL_PTR
> hFunc := GetProcAddress(hLib,PSZ("Send"))
> ENDIF
> ENDIF
>
> IF hFunc <> NULL_PTR
> SELF:_IsValid := TRUE
> ENDIF
>
> SELF:DestList := {}
> SELF:CCList := {}
> SELF:BCCList := {}
> SELF:AttachMents := {}
>
> RETURN SELF
>
> ACCESS IsValid AS LOGIC PASCAL CLASS BlatMail
> RETURN SELF:_IsValid
> METHOD Send() CLASS BlatMail
> LOCAL nResult AS INT
> LOCAL cCmd AS STRING
> LOCAL pCmd AS PSZ
>
> cCmd := SELF:CommandLine
>
> // TextBox{,"Cmd",cCmd,BUTTONOKAY}:Show()
>
>
> IF !Empty(SELF:_LogFile)
> FErase(SELF:_LogFile)
> ENDIF
>
> pCmd := StringAlloc(cCmd)
> nResult := INT(_CAST,PCALL(hFunc,pCmd))
> MemFree(pCmd)
>
> IF !Empty(SELF:_LogFile)
> SELF:ResultString := MemoRead(SELF:_LogFile)
> FErase(SELF:_LogFile)
> ELSE
> SELF:ResultString := ""
> ENDIF
>
> RETURN nResult
>
> STATIC GLOBAL hFunc AS PTR
>
> FUNCTION TestBlatMail() AS LOGIC
> LOCAL nResult AS INT
> LOCAL oMail AS BlatMail
>
> oMail := BlatMail{}
>
> IF oMail:IsValid
>
> oMail:Server := "xxx.yyy.zzz.a"
>
> oMail:FromAddress := "info@xxx.de"
> oMail:DestList := {"aa@bbb.de"}
> oMail:Subject := 'Testmail mit "Blat.DLL"'
> oMail:MailBody := "testmail"+CRLF+'Nummer
> "1"'+CHR(9)+'"XXXXXXX"'+CRLF+CRLF+"Ende"
>
> oMail:AddAttachment("C:\test.pdf","order.pdf")
>
> nResult := oMail:Send()
> IF nResult <> 0
> InfoBox{,,NTrim(nResult)+CRLF+oMail:ResultString}:Show()
> ENDIF
>
> ELSE
> InfoBox{,"Fehler","BlatMail kann nicht initialisiert werden"}:Show()
> ENDIF
>
> RETURN (nResult=0)
>
>
>
> HTH
> Karl
>
> Am 08.03.2013 04:56, schrieb baksoftgroup@gmail.com:
>> Has anyone used BLAT from inside VO to send emails?
>> If so, was it successful? And can you share any code?
>> Cheers
>> Kevin
>>
[toc] | [prev] | [next] | [standalone]
| From | marc3l0 <mmarloch@gmail.com> |
|---|---|
| Date | 2013-03-08 06:28 -0800 |
| Message-ID | <d080f0c0-ea3c-4be9-98bd-6c524e70c528@googlegroups.com> |
| In reply to | #4887 |
I used a similar tool... senditquiet... google it if you want... it did the job I need...
I make a nice looking HTML body and atatch the files I need
heres my code, its in portuguese but i think you'll understand if not I can make a translation...
METHOD SenditQuiet() CLASS TelaListagens01
LOCAL sComando, sConta, sDestino, sAssunto, sTexto, sAnexo AS STRING
LOCAL oEmpresaUso AS PGSQLSelect
LOCAL sBat AS STRING
LOCAL oArq AS PTR
sComando := 'c:\vo\senditquiet.exe -s '
sConta := ' smtp.yourserver.net -port 587 -u youremail@yourserver.net -protocol normal -p yourpassword -f youremail@yourserver.net '
sDestino := ' -t toemail@xxx.com'
sAssunto := ' -subject "Your Subject"'
SELF:MakeMailBody()
sTexto := ' -bodyfile "c:\emailbody.html" '
sAnexo := ' -files '+'C:\file.zip'
sBat := sComando+sConta+sDestino+sAssunto+sTexto+sAnexo
sBat+=CHR(13)+CHR(10)
sBat+='PAUSE'
oArq := FCreate('c:\vo\sendit.bat',FC_NORMAL)
IF FWrite(oArq,sBat)
ENDIF
FClose(oArq)
RUN('c:\vo\sendit.bat')
RETURN SELF
//code for email body
METHOD MakeMailBody()CLASS TelaListagens01
LOCAL sBody AS STRING
LOCAL oArq AS PTR
sBody := '<HEAD> '+;
'<TITLE>NF-e RUMONOVO/MKF/VOOK</TITLE> '+;
'</HEAD> '+;
'<BODY BGCOLOR="WHITE"> '+;
'<DIV ALIGN = LEFT> '+;
'<H1>TEXT SIZE 1!</H1>'+;
'<H2>TEXT SIZE 2</H2>'+;
'<H2>TEXT SIZE 2</H2>'+;
'<P>'+;
'<H3>TEXT SIZE 3</H3> '+;
'<H3>TEXT SIZE 3</H3> '+;
'<IMG SRC="http://www.your-image-adress.jpg"> '+;
'</DIV> '+;
'</BODY>'
oArq := FCreate('c:\emailbody.html',FC_NORMAL)
IF FWrite(oArq,sBody)
ENDIF
FClose(oArq)
RETURN SELF
[toc] | [prev] | [next] | [standalone]
| From | baksoftgroup@gmail.com |
|---|---|
| Date | 2013-03-11 13:47 -0700 |
| Message-ID | <657b5899-744b-4a8b-ae47-a77d7e633870@googlegroups.com> |
| In reply to | #4887 |
On Friday, March 8, 2013 4:56:53 PM UTC+13, baksof...@gmail.com wrote: > Has anyone used BLAT from inside VO to send emails? > > If so, was it successful? And can you share any code? > > Cheers > > Kevin Thanks Karl and Marc. Much appreciated. Saved me a lot of time!
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.clipper.visual-objects
csiph-web