Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

email automation

Status
Not open for further replies.

lvadmin

MIS
May 5, 2004
28
US
I have this important program running on the server. Now in the event that a certain error occurs, It email about 10 different email addresses.

Anyways I get sick of modifying the .prg file all the time. Does anyone know of a way I can have it email every record in a .dbf file......where each record contains someone email address?
 
just:

Code:
SELECT 0
USE myEmailDBF
SCAN
  DO SendMail with MyEmailDBF.Address
ENDSCAN

What method are you using to send the emails?

- Bill

Get the best answers to your questions -- See FAQ481-4875.
 
I figured it out anyways I'm now having problems because the string is too large (me message is too big) does anyone have a way around this?
 
lvadmin

Can you post your code so we can determine where the problem is?

Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first.
 

Code is below, I am running into size limitations for my lcbody, does anyone have a way around this?


************************************************************
*!* Sample code using SendEmail procedure
DIMENSION aryAttach(1)

aryAttach(1) = "C:\an attached file i would like to send.txt"
lcFrom = "myemailaddress@whatever.com"
&&lcTo is inserted by another program and keeps looping this .prg until i used all my email address I am sending to
lcSubject = "blah blah blah........"

lcBody = "This is where I want my message but I'm running into size limitations, please help "

FOR lnCount = 1 TO 1
=SendEmail(lnCount, lcFrom, lcTo, lcSubject, lcBody, @aryAttach)
ENDFOR


PROCEDURE SendEmail(tcType, tcFrom, tcTo, tcSubject, tcBody, tcFiles)
LOCAL llEmailStatus, lcErrorHandlerWas, lcType
lcErrorHandlerWas = ON("ERROR")
lcType = ""
WAIT WINDOW " One Moment... Email is being generated and sent " NOWAIT
DO CASE
CASE tcType = 1
llEmailStatus = SendViaMAPI(tcFrom, tcTo, tcSubject, tcBody)
lcType = "MAPI"

ENDCASE

WAIT CLEAR

ENDPROC

FUNCTION SendViaMAPI(tcFrom, tcTo, tcSubject, tcBody)
ON ERROR RETURN(.F.)
LOCAL loSession, loMessages
loSession = CREATEOBJECT( "MSMAPI.MAPISession" )
loSession.Signon()
IF (loSession.SessionID > 0)
loMessages = CREATEOBJECT( "MSMAPI.MAPIMessages" )
loMessages.SessionID = loSession.SessionID
ENDIF
WITH loMessages
.Compose()
.RecipDisplayName = tcTo
.RecipType = 1
.ResolveName()
.MsgSubject = tcSubject
.MsgNoteText = tcBody
.SEND(.F.)
ENDWITH
loSession.Signoff()
STORE .NULL. to loSession, loMessages
RELEASE loSession, loMessages
RETURN .T.
ENDFUNC






 

The way your are storing you lcBody, it would limited to 255 characters. Have you reached that limit?


Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first.
 
yes, I really need to get a work around.....does anyone know how to get past 255?

Does a memo work?

PLEASE HELP!

Thanks,

Ross
 
lvadmin

Does a memo work?

Code:
 WITH loMessages
        .Compose()
        .RecipDisplayName = tcTo
        .RecipType = 1
        .ResolveName()
        .MsgSubject = tcSubject
        .MsgNoteText = alltrim(myTable.mymemo) 
        .SEND(.F.)
    ENDWITH


Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first.
 
I assume that the character limit you are encountering is within the memory variable tcBody itself.

Have you considered analyzing your Body message as it is being composed and breaking it into more than one string?

Then your code could appear as:
Code:
 WITH loMessages
        .Compose()
        .RecipDisplayName = tcTo
        .RecipType = 1
        .ResolveName()
        .MsgSubject = tcSubject
        .MsgNoteText = tcBody1 + tcBody2 + tcBody3 + tcBody4
        .SEND(.F.)
    ENDWITH

Good Luck,
JRB-Bldr
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top