Lew wrote:
> Ok, success. After some hair pulling and screaming in my brain, here's what 
> works: NEITHER authenticated nor
> non-authenticated login is accepted when using the smpt server provided by my 
> isp. The -f switch identifies my
> user account. Additionally, contrary to popular belief, the -log <filename> 
> switch does work. You just have to
> issue clear dlls to open the file. Of course, Outlook is running on my 
> desktop, so if the login was required,
> it would already have been done. I guess I'll have to test & see what happens 
> when Outlook isn't running.
> -Lew
>
>   
Hooray for you!  I know how good it feels when you get the bugger 
working.  I took Grigore's procedure code earlier today and put it into 
a class.  My latest test seems to indicate that it works as he said it 
would too!  <g>  Here's the class code with test code above it:

    * mjb 05-30-07 use BLAT class from Grigore Dolghin (ProFox)
    loEmail = NEWOBJECT("_Email",".\progs\SendEmail.fxp")
    WITH loEmail
                .cBodyText = lcBodyText
                .cToEmailAddress = cErrorEmailTo
                .cCCEmailAddress = ""
                .cSubject = "[BUG " + this.cVersion + "] " +
    ALLTRIM(TRANSFORM(tnErrNum)) + ": " + ALLTRIM(tcErrMsg)
                .cAttachment = FULLPATH("bugrpt.zip")
                .cMailServer = "smtp.yoururl.net"
                .nPort = 25
                .cFromEmailAddress = cErrorEmailFrom
                .cUserName = "[EMAIL PROTECTED]"
                .cPassword = "pwd"
                .cCompanyName = "MB Software Solutions"
                .cSupportEmail = "[EMAIL PROTECTED]"
    ENDWITH
    loEmail.SendEmail()

    DEFINE CLASS _Email AS Custom
    * BLAT wrapper class, taken from Grigore Dolghin's post on ProFox,
    30-May-2007.
    * Michael J. Babcock, [EMAIL PROTECTED], 05-30-2007
        Name = "_Email"
        cBodyText = ""
        cToEmailAddress = ""
        cCCEmailAddress = ""
        cSubject = ""
        cAttachment = ""
        cMailServer = ""
        nPort = 25
        cFromEmailAddress = ""
        cUserName = ""
        cPassword = ""
       
        cMsg = ""
        nBtns = 0
        lError = .F.
       
        cCompanyName = "ACME Company"
        cSupportEmail = "[EMAIL PROTECTED]"
       
        *---------------------------------
        PROCEDURE Init
            *-- Declare the API functions.
            Declare Integer Send ;
             In blat.dll ;
             String cParam

            Declare Integer GetShortPathNameA ;
             In Win32API As GetShortPathName ;
             String, ;
             String, ;
             Integer
       
        ENDPROC && Init
       
       
        PROCEDURE Error(tnError as Integer, tcMethod as String, tnLine
    as Integer)
            this.cMsg = "Error " + ALLTRIM(STR(tnError)) + ", Method " +
    ALLTRIM(tcMethod) + ", Line " + ALLTRIM(STR(tnLine))
            this.nBtns = 16
            this.lError = .T.
        ENDPROC


        PROCEDURE LogMsg(tcMsg as String)
        * Logs message from procedures.
            IF EMPTY(this.cMsg) THEN
                this.cMsg = tcMsg
            ELSE
                this.cMsg = CHR(13) + CHR(10) + this.cMsg
            ENDIF
        ENDPROC
       

        FUNCTION SendEmail() as Integer
            Local lcParameterString As String, lcBodyFileName as String,
    lcBuffer as String, lnReturn as Integer, lcBodyFileShortName as
    String, ;
                    lcAttachmentFileShortName as String

            *-- create the parameter string variable:
            lcParameterString = SPACE(5000)

            *-- create the message body
            lcBodyFileName = "_" + Right(Sys(2015),7)
            StrToFile(this.cBodyText,lcBodyFileName,0)
            lcBodyFileName = FullPath(lcBodyFileName)

            *-- get the short (msdos) file name (required by blat)
            lcBuffer = Space(255)
            lnReturn = GetShortPathName(lcBodyFileName, @lcBuffer,255)
            lcBodyFileShortName = Left(lcBuffer,lnReturn)

            *-- store the shortfilename into parameter string
            lcParameterString = lcBodyFileShortName + " " && careful
    with the spaces. One single extra space and blat fails.

            *-- add TO address to parameter string
            lcParameterString = lcParameterString + "-to " +
    this.cTOEmailAddress + " "

            *-- add the CC address to parameter string
            If Vartype(this.cCCEmailAddress) = "C" And Not
    Empty(Alltrim(this.cCCEmailAddress))
             lcParameterString = lcParameterString + "-cc " +
    this.cCCEmailAddress + " "
            EndIf

            *-- add the subject to parameter string:
            If Vartype(this.cSubject) <> "C" Or
    Empty(Alltrim(this.cSubject))
             this.cSubject = "Automated email from " + this.cCompanyName
            EndIf
            lcParameterString = lcParameterString + [-subject "] +
    this.cSubject + [" ]

            *-- get the attachment's short (msdos) filename
            If Vartype(this.cAttachment) = "C" And Not
    Empty(this.cAttachment)
             lcBuffer = Space(255)
             lnReturn = GetShortPathName(this.cAttachment, @lcBuffer,255)
             lcAttachmentFileShortName = Left(lcBuffer,lnReturn)
             *-- and add it to parameter string:
             lcParameterString = lcParameterString + [-attach "] +
    lcAttachmentFileShortName + [" ]
            EndIf

            *-- get the mail server:
            If Vartype(this.cMailServer) = "C" And Not
    Empty(this.cMailServer) THEN
             lcParameterString = lcParameterString + "-server " +
    Alltrim(this.cMailServer) + " "
            Else
             This.LogMsg("Error. Mail server not defined.")
             Return .F.
            EndIf

            *-- add the port to string parameter:
            lcParameterString = lcParameterString + "-port " +
    Transform(this.nPort) + " "

            *-- add the "FROM" email address:
            lcParameterString = lcParameterString + "-f " +
    this.cFromEmailAddress + " "

            *-- Add the smtp username:
            lcParameterString = lcParameterString + "-u " +
    this.cUserName + " "

            *-- add the smtp password:
            lcParameterString = lcParameterString + "-pw " + this.cPassword

            lnResult = Send(lcParameterString)

            If lnResult = 0
             This.LogMsg("    Mail to " + this.cTOEmailAddress + " was
    sent succesfully.")
            Else
             This.LogMsg("    Error sending email to " +
    this.cTOEmailAddress + ". Error code is " + Transform(lnResult))
             This.LogMsg("    BLAT.DLL parameter: " + lcParameterString)
             This.LogMsg("    If you see this error in the activity log
    file, please forward the report email to " + this.cSupportEmail + ".")
            ENDIF
            RETURN lnResult
        ENDFUNC
    *-----------------

    ENDDEFINE && _Email

Again, thanks to Grigore, Bob, Peter, Garrett, and the others who 
contributed on this.  It's really their code...I just put it into a 
class.  I've uploaded this to Ed's downloads site too so others might be 
able to download/use/improve on this in the future.

-- 
Michael J. Babcock, MCP
MB Software Solutions, LLC
http://mbsoftwaresolutions.com
http://fabmate.com
"Work smarter, not harder, with MBSS custom software solutions!"



_______________________________________________
Post Messages to: ProFox@leafe.com
Subscription Maintenance: http://leafe.com/mailman/listinfo/profox
OT-free version of this list: http://leafe.com/mailman/listinfo/profoxtech
Searchable Archive: http://leafe.com/archives/search/profox
This message: http://leafe.com/archives/byMID/profox/[EMAIL PROTECTED]
** All postings, unless explicitly stated otherwise, are the opinions of the 
author, and do not constitute legal or medical advice. This statement is added 
to the messages for those lawyers who are too stupid to see the obvious.

Reply via email to