Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Email
Message
General information
Forum:
Visual FoxPro
Category:
Windows API functions
Title:
Re: Email
Miscellaneous
Thread ID:
00635974
Message ID:
00635986
Views:
23
Hi,

This might give you some ideas.
Select(Alias())
Go 1
oleMAPISession = Createobject( "MSMAPI.MAPISession.1" )
Select(Thisform.DB_name.Value)
Go Top
the_email=Alltrim(Thisform.DB_name.Value)+"."+Alltrim(Thisform.email_field.Value)
* Signon to mail
With oleMAPISession
    .UserName = Thisform.user_name.Value
    .Password = Thisform.pass_wd.Value
    .Signon()
    * Check the SignOn status
    If (.SessionID > 0)
        oleMAPIMessages = Createobject( "MSMAPI.MAPIMessages.1" )
        * tell the message the SessionID
        oleMAPIMessages.SessionID = .SessionID
    Else
        Return
    Endif
Endwith
Count=1
* Send an email
With oleMAPIMessages
    Do While .Not. Eof()  && Loop to step through database
        If .Not. Empty(&the_email)  && Do Not try to process empty email fields
           .Compose()
            * Set the Recipient name and resolve
            .RecipDisplayName = Alltrim(&the_email)  
            .RecipType = 1
            .ResolveName()
            .MsgSubject = Thisform.subject.Value
            &&            .MsgNoteText ="Hello dear" && tested
            &&            .MsgNoteText = _CLIPTEXT && tested
            &&            .htmlbody = "<HTML><H2>This is HTML Mail.</H2><BODY>"  && Outlook Only && Tested
            &&            .MsgNoteText = Filetostr(Thisform.path_to_message.Value) && Tested
            .MsgNoteText="For Outlook Express - Click on source tab and past text, HTML"
            If .Not. Empty(Thisform.path_to_attachment.Value)  && Skip if no path to attachment
                .AttachmentPathName=(Thisform.path_to_attachment.Value)  && Full path and filename
            Endif
            If Count=1
                .Send(1)  && On first pass stop mail client to get message
            Else
                .Send(.F.) && On all subsequent passes send email without stopping
            Endif
            Wait Window Str(Count)+'   '+(&the_email) Timeout 1  && Timeout 1 second so as not to put mail server into shock
            Count=Count+1
        Endif
        Skip
    Enddo
    oleMAPISession.Signoff() &&Remember to close mail client
Endwith
Return
Leland F. Jackson, CPA
Software - Master (TM)
smvfp@mail.smvfp.com
Software Master TM
Previous
Reply
Map
View

Click here to load this message in the networking platform