Home > Archive > Programming with dBASE > October 2005 > Sending email info to Outlook









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Sending email info to Outlook
Rick

2005-10-11, 7:27 am

I would like to allow users to pick recipients of an email from my own tables, to enter a subject, and to pick a standard email message, all before they run Outlook Express or Outlook. When OE or Outlook opens, it would contain the information users sele
cted (i.e., To, CC, subject, and message).

My question, does anyone know if OE or Outlook can receive this info when it is run thru OLE, and any timps or any info on where do I start to find how to info?

Any ideas much appreciated,
Rick
Pat Curran

2005-10-11, 7:27 am

Hi Rick;

I am happy that I can finally reply to a question on the group instead of
always asking for help:-). Yes is is possible...I do it all the time with
outlook 2003. Here is the code I use:

m = new OLEAutoClient("Outlook.Application")
item = m.CreateItem(0)
item.recipients.Add(m_email)
item.subject = "<Subject line text>"
item.body = " <body of email>"
item.display()
*item.send()
ShowApp("<Subject")
return

With the item.send() line removed, the message will open ready for you to
type in the body and header. m_email is the variable for the email or you
could also use a field from a table. You could also have your body or
subject a variable or a field and adjust the lines as appropriate.

If your ultimate goals is to send emails to multiple people automatically
with out your user having to view the item and click send, you will need
this freeware app to bypass outlooks security features. I will try to look
for the file and get back to you on it.

Pat


"Rick" <Sportman7@netzero.net> wrote in message
news:TiVNQl1yFHA.1412@news-server...
>I would like to allow users to pick recipients of an email from my own
>tables, to enter a subject, and to pick a standard email message, all
>before they run Outlook Express or Outlook. When OE or Outlook opens, it
>would contain the information users selected (i.e., To, CC, subject, and
>message).
>
> My question, does anyone know if OE or Outlook can receive this info when
> it is run thru OLE, and any timps or any info on where do I start to find
> how to info?
>
> Any ideas much appreciated,
> Rick



Rick

2005-10-11, 7:27 am

Pat,

That is good news. Just a couple more questions:

- Could this same thing be done with Outlook Express?

- Is there a way to also obtain the message back from Outlook so I can save it should they make any changes, i.e., user would create the message in my app, send the message to Outlook and open Outlook. Make some changes in Outlook to the message, then se
nd the email. If they make changes, I would like to record the final email message they sent if possible.

Thanks again,
Rick


Pat Curran Wrote:

> Hi Rick;
>
> I am happy that I can finally reply to a question on the group instead of
> always asking for help:-). Yes is is possible...I do it all the time with
> outlook 2003. Here is the code I use:
>
> m = new OLEAutoClient("Outlook.Application")
> item = m.CreateItem(0)
> item.recipients.Add(m_email)
> item.subject = "<Subject line text>"
> item.body = " <body of email>"
> item.display()
> *item.send()
> ShowApp("<Subject")
> return
>
> With the item.send() line removed, the message will open ready for you to
> type in the body and header. m_email is the variable for the email or you
> could also use a field from a table. You could also have your body or
> subject a variable or a field and adjust the lines as appropriate.
>
> If your ultimate goals is to send emails to multiple people automatically
> with out your user having to view the item and click send, you will need
> this freeware app to bypass outlooks security features. I will try to look
> for the file and get back to you on it.
>
> Pat
>
>
> "Rick" <Sportman7@netzero.net> wrote in message
> news:TiVNQl1yFHA.1412@news-server...
>
>


Pat Curran

2005-10-11, 7:27 am

Hi Rick;
The name of the file I was referring to is "Advaced Security for Outllook"
It is freeware at http://www.mapilab.com/ . If you wanted to send multiple
emails through your app, on EVERY MESSAGE you will recieve a popup that says
"A Program is Trying To Access Outlook...Would you Like to Allow This?" The
OK buttun is greyed out for 5 seconds to give you the chance to read the
message. When you can finally click OK it sends the ONE message, and then
repeats the procedure all over again for the next message. If you are
sending out 50 messages, it is a real pain. If you install the app I spoke
of, you will recieve a similar message, but only once. So you could send out
50 or more emails with only one click of "allow access".

As far as Outlook Express goes, I dont really use it. We use a MS Exchange
Server with outlook installed on all machines so that is what I did my app
in. You can also configure Outlook to use internet pop3 mail. At the house
my Outlook is configured for "Hotmail"

It is possible to write the changed message back to your app but it would be
more work. I send some of my data to excel tables and manipulate the excel
tables and save the data back to my dbf so it is possible. Remember though,
that all sent messages are automatically saved in your Sent Items folder in
outlook on your harddrive so in a sence you have that already.

My app that I wrote, sends out automatic emails for reminders of things. As
a result, I dont really care to save in my app what was sent because it was
all based on certain dates weather an email is sent or not.

I wrote my app in vdBase 5.7 If you need any sample code let me know.
Good Luck
Pat


Pat Couture

2005-10-11, 7:27 am

Hello!

I am experiencing the same problem. The issue is not related to dBase, but to XP and Exchange. I'm told by our network administrator that there's a patch available for Exchange, but we have not installed it due to some security concerns on our network.


It works Great if the machine is running Windows 98.

Pat Couture


Pat Curran Wrote:

> Hi Rick;
> The name of the file I was referring to is "Advaced Security for Outllook"
> It is freeware at http://www.mapilab.com/ . If you wanted to send multiple
> emails through your app, on EVERY MESSAGE you will recieve a popup that says
> "A Program is Trying To Access Outlook...Would you Like to Allow This?" The
> OK buttun is greyed out for 5 seconds to give you the chance to read the
> message. When you can finally click OK it sends the ONE message, and then
> repeats the procedure all over again for the next message. If you are
> sending out 50 messages, it is a real pain. If you install the app I spoke
> of, you will recieve a similar message, but only once. So you could send out
> 50 or more emails with only one click of "allow access".
>
> As far as Outlook Express goes, I dont really use it. We use a MS Exchange
> Server with outlook installed on all machines so that is what I did my app
> in. You can also configure Outlook to use internet pop3 mail. At the house
> my Outlook is configured for "Hotmail"
>
> It is possible to write the changed message back to your app but it would be
> more work. I send some of my data to excel tables and manipulate the excel
> tables and save the data back to my dbf so it is possible. Remember though,
> that all sent messages are automatically saved in your Sent Items folder in
> outlook on your harddrive so in a sence you have that already.
>
> My app that I wrote, sends out automatic emails for reminders of things. As
> a result, I dont really care to save in my app what was sent because it was
> all based on certain dates weather an email is sent or not.
>
> I wrote my app in vdBase 5.7 If you need any sample code let me know.
> Good Luck
> Pat
>
>


Rick

2005-10-11, 7:27 am

Pat,

Thanks for the info. Just a couple questions:

- Be interested in that sample code when you get a chance.

- You said you write data out to excel, is that Outllook data to Excel?

Thanks,
Rick

Pat Curran Wrote:

> Hi Rick;
> The name of the file I was referring to is "Advaced Security for Outllook"
> It is freeware at http://www.mapilab.com/ . If you wanted to send multiple
> emails through your app, on EVERY MESSAGE you will recieve a popup that says
> "A Program is Trying To Access Outlook...Would you Like to Allow This?" The
> OK buttun is greyed out for 5 seconds to give you the chance to read the
> message. When you can finally click OK it sends the ONE message, and then
> repeats the procedure all over again for the next message. If you are
> sending out 50 messages, it is a real pain. If you install the app I spoke
> of, you will recieve a similar message, but only once. So you could send out
> 50 or more emails with only one click of "allow access".
>
> As far as Outlook Express goes, I dont really use it. We use a MS Exchange
> Server with outlook installed on all machines so that is what I did my app
> in. You can also configure Outlook to use internet pop3 mail. At the house
> my Outlook is configured for "Hotmail"
>
> It is possible to write the changed message back to your app but it would be
> more work. I send some of my data to excel tables and manipulate the excel
> tables and save the data back to my dbf so it is possible. Remember though,
> that all sent messages are automatically saved in your Sent Items folder in
> outlook on your harddrive so in a sence you have that already.
>
> My app that I wrote, sends out automatic emails for reminders of things. As
> a result, I dont really care to save in my app what was sent because it was
> all based on certain dates weather an email is sent or not.
>
> I wrote my app in vdBase 5.7 If you need any sample code let me know.
> Good Luck
> Pat
>
>


Pat Curran

2005-10-11, 7:27 am

Rick...I wrote this out tonight. It should work. I use visual dBase 5.7 Save
the below text as temp1025.prg and run it from the dot prompt.

As for excel, I send a lot of my table data that is stored in dbf tables to
excel and to outlook. The outlook stuff is notes and calendar events that
get synced to my PDA.

Dont forget to get the Advanced Security for Outllok that I told you
about...

********************
********************
*
***Temp1025.prg
* Save this text as temp1025.prg
* and then run it from the dot prompt
* it will create a temp table and populate it
* Then it will send out emails
* Watch for wordwrap!!!
********************
********************
*
#define VALID_CHARS
" 0123456789abcdefghij
klmnñopqrstuvwxyzABC
DEFGHIJKLMNOPQRSTUVW
XYC@-_.'"
#define FOUR_LETTER_TLDS ".name|.info|.fake"
if file('Temp1025.dbf')
erase temp1025.dbf
endif
if .not. file('Temp1025.dbf')
create table "Temp1025.DBF" ( ;
Temp1025.'NAME' CHAR(15),;
Temp1025.'email' CHAR(25),;
Temp1025.'Subject' CHAR(80),;
Temp1025.'body' blob)
endif
USE temp1025 in SELECT()
SELECT temp1025
generate 15


** END HEADER -- do not remove this line*
* Generated on 10/11/05
*
parameter bModal
local f
f = new TEMP1025FORM()
if (bModal)
f.mdi = .F. && ensure not MDI
f.ReadModal()
else
f.Open()
endif
CLASS TEMP1025FORM OF FORM
this.Left = 34.166
this.OnClose = {;Use in temp1025}
this.Top = 1.2344
this.Height = 6.1172
this.Text = "Example Email Form"
this.Width = 60

DEFINE ENTRYFIELD ENTRYFIELD1 OF THIS;
PROPERTY;
FontBold .F.,;
Left 7,;
Top 1.4102,;
Height 1.4102,;
Width 45.5,;
OnChange CLASS::ENTRYFIELD1_O
NCHANGE,;
Value "",;
MaxLength 50

DEFINE TEXT TEXT1 OF THIS;
PROPERTY;
FontBold .F.,;
Left 7,;
Top 0.4688,;
Height 0.7637,;
Text "Please enter an email address:",;
Width 25.5

DEFINE PUSHBUTTON PUSHBUTTON1 OF THIS;
PROPERTY;
FontBold .F.,;
Left 23,;
Top 3.7637,;
Height 1.1172,;
Text "Send Emails",;
Width 11.8311,;
OnClick CLASS::PUSHBUTTON1_O
NCLICK,;
Group .T.

Procedure ENTRYFIELD1_OnChange

replace all temp1025->email with form.entryfield1.value
return

Procedure PUSHBUTTON1_OnClick
SELECT temp1025
LOCAL emailvalid, cAddress
scan
emailvalid = .f.
store ltrim(rtrim(temp1025
->email)) TO cAddress
do case
case len( cAddress ) < 5 && chk length
*// a@b.c should be the shortest an
*// address could be
emailvalid = .f.
m_error = 'is not 5 Charactors in Length'

case .not. "@" $ cAddress && chk format has at least one "@"
emailvalid = .f.
m_error = 'does Not Contain "@"'

case .not. "." $ cAddress && has at least one "."
emailvalid = .f.
m_error = 'does Not Contain "."'

case len(cAddress)-rat(".", cAddress) > 3 .and. ; && has no
more than 3 chars after last "."
.not. (lower(substr(cAddre
ss, rat(".",cAddress))) $
FOUR_LETTER_TLDS)
emailvalid = .f.
m_error = 'has more than three letters after the last "."'

case rat( "_", cAddress ) > rat( "@", cAddress ) && has no "_" after
the "@"
emailvalid = .f.
m_error = 'has a "_" after the "@"'
case at( "@", cAddress, 2 ) > 0 && has only one "@"
emailvalid = .f.
m_error = 'has more than one "@"'
case left( cAddress, 1 ) = "@" && has only one "@"
emailvalid = .f.
m_error = 'starts with "@"'
otherwise
emailvalid = .t.
endcase

if emailvalid = .t.
for i = 1 to len( cAddress ) &&// chk each char for validity
if .not. substr( cAddress, i, 1 ) $ VALID_CHARS
emailvalid = .f.
m_error = "contains an invalid character: '" + substr( cAddress,
i, 1 ) + "'"
exit
endif
next
endif

if emailvalid = .t.

REPLACE temp1025->subject with 'This is the Email Example Subject'
REPLACE temp1025->body with 'Dear
'+ltrim(rtrim(temp10
25->name))+';'+chr(13) +'The Current date is '+
dtoc(date()) +Chr(13) + 'The Current Time is '+ time() +chr(13) + 'This is
an example of the email body'
m = new OLEAutoClient("Outlook.Application")
item = m.CreateItem(0) &&//zero is the constant for mail item
item.to = temp1025->email
**** item.cc = <field->name> && if you need to use it...
item.subject = temp1025->subject
item.body = temp1025->body
item.send()
if type("m.Assistant") <> 'O'
m.quit()
endif
RELEASE item
RELEASE OBJECT m
m = null

else
msgbox(cAddress +' appears to be Invalid belonging to
'+ltrim(rtrim(temp10
25->name))+'.' +chr(13)+' The email address ' +
m_error,'Alert',64)
endif
endscan
RETURN




ENDCLASS


Pat Curran

2005-10-11, 7:27 am

I am using Advanced Security for Outlook on a Windows XP machine with a
Microsoft Exchange Server. I am also running MS Office 2003. It works great!
I quit having issues once I installed it.


Rick

2005-10-12, 11:24 am

Pat,

Thanks for being so helpful. This code will help me better understand how to.

I also send lots of dbf table data to Excel, but not to Outlook. If I am not imposing too much more than I have, could you post some sample code on how you write calendar data out to the Outlook calendar. Part of my app has a calendar and would love to
allow users to write out that data to Outlook as you are doing.

Many thanks again for your help on this,
Rick

Pat Curran Wrote:

> Rick...I wrote this out tonight. It should work. I use visual dBase 5.7 Save
> the below text as temp1025.prg and run it from the dot prompt.
>
> As for excel, I send a lot of my table data that is stored in dbf tables to
> excel and to outlook. The outlook stuff is notes and calendar events that
> get synced to my PDA.
>
> Dont forget to get the Advanced Security for Outllok that I told you
> about...
>
> ********************
********************
*
> ***Temp1025.prg
> * Save this text as temp1025.prg
> * and then run it from the dot prompt
> * it will create a temp table and populate it
> * Then it will send out emails
> * Watch for wordwrap!!!
> ********************
********************
*
> #define VALID_CHARS
> " 0123456789abcdefghij
klmnñopqrstuvwxyzABC
DEFGHIJKLMNOPQRSTUVW
XYC@-_.'"
> #define FOUR_LETTER_TLDS ".name|.info|.fake"
> if file('Temp1025.dbf')
> erase temp1025.dbf
> endif
> if .not. file('Temp1025.dbf')
> create table "Temp1025.DBF" ( ;
> Temp1025.'NAME' CHAR(15),;
> Temp1025.'email' CHAR(25),;
> Temp1025.'Subject' CHAR(80),;
> Temp1025.'body' blob)
> endif
> USE temp1025 in SELECT()
> SELECT temp1025
> generate 15
>
>
> ** END HEADER -- do not remove this line*
> * Generated on 10/11/05
> *
> parameter bModal
> local f
> f = new TEMP1025FORM()
> if (bModal)
> f.mdi = .F. && ensure not MDI
> f.ReadModal()
> else
> f.Open()
> endif
> CLASS TEMP1025FORM OF FORM
> this.Left = 34.166
> this.OnClose = {;Use in temp1025}
> this.Top = 1.2344
> this.Height = 6.1172
> this.Text = "Example Email Form"
> this.Width = 60
>
> DEFINE ENTRYFIELD ENTRYFIELD1 OF THIS;
> PROPERTY;
> FontBold .F.,;
> Left 7,;
> Top 1.4102,;
> Height 1.4102,;
> Width 45.5,;
> OnChange CLASS::ENTRYFIELD1_O
NCHANGE,;
> Value "",;
> MaxLength 50
>
> DEFINE TEXT TEXT1 OF THIS;
> PROPERTY;
> FontBold .F.,;
> Left 7,;
> Top 0.4688,;
> Height 0.7637,;
> Text "Please enter an email address:",;
> Width 25.5
>
> DEFINE PUSHBUTTON PUSHBUTTON1 OF THIS;
> PROPERTY;
> FontBold .F.,;
> Left 23,;
> Top 3.7637,;
> Height 1.1172,;
> Text "Send Emails",;
> Width 11.8311,;
> OnClick CLASS::PUSHBUTTON1_O
NCLICK,;
> Group .T.
>
> Procedure ENTRYFIELD1_OnChange

> replace all temp1025->email with form.entryfield1.value
> return
>
> Procedure PUSHBUTTON1_OnClick
> SELECT temp1025
> LOCAL emailvalid, cAddress
> scan
> emailvalid = .f.
> store ltrim(rtrim(temp1025
->email)) TO cAddress
> do case
> case len( cAddress ) < 5 && chk length
> *// a@b.c should be the shortest an
> *// address could be
> emailvalid = .f.
> m_error = 'is not 5 Charactors in Length'
>
> case .not. "@" $ cAddress && chk format has at least one "@"
> emailvalid = .f.
> m_error = 'does Not Contain "@"'
>
> case .not. "." $ cAddress && has at least one "."
> emailvalid = .f.
> m_error = 'does Not Contain "."'
>
> case len(cAddress)-rat(".", cAddress) > 3 .and. ; && has no
> more than 3 chars after last "."
> .not. (lower(substr(cAddre
ss, rat(".",cAddress))) $
> FOUR_LETTER_TLDS)
> emailvalid = .f.
> m_error = 'has more than three letters after the last "."'
>
> case rat( "_", cAddress ) > rat( "@", cAddress ) && has no "_" after
> the "@"
> emailvalid = .f.
> m_error = 'has a "_" after the "@"'
> case at( "@", cAddress, 2 ) > 0 && has only one "@"
> emailvalid = .f.
> m_error = 'has more than one "@"'
> case left( cAddress, 1 ) = "@" && has only one "@"
> emailvalid = .f.
> m_error = 'starts with "@"'
> otherwise
> emailvalid = .t.
> endcase
>
> if emailvalid = .t.
> for i = 1 to len( cAddress ) &&// chk each char for validity
> if .not. substr( cAddress, i, 1 ) $ VALID_CHARS
> emailvalid = .f.
> m_error = "contains an invalid character: '" + substr( cAddress,
> i, 1 ) + "'"
> exit
> endif
> next
> endif
>
> if emailvalid = .t.
>
> REPLACE temp1025->subject with 'This is the Email Example Subject'
> REPLACE temp1025->body with 'Dear
> '+ltrim(rtrim(temp10
25->name))+';'+chr(13) +'The Current date is '+
> dtoc(date()) +Chr(13) + 'The Current Time is '+ time() +chr(13) + 'This is
> an example of the email body'
> m = new OLEAutoClient("Outlook.Application")
> item = m.CreateItem(0) &&//zero is the constant for mail item
> item.to = temp1025->email
> **** item.cc = <field->name> && if you need to use it...
> item.subject = temp1025->subject
> item.body = temp1025->body
> item.send()
> if type("m.Assistant") <> 'O'
> m.quit()
> endif
> RELEASE item
> RELEASE OBJECT m
> m = null
>
> else
> msgbox(cAddress +' appears to be Invalid belonging to
> '+ltrim(rtrim(temp10
25->name))+'.' +chr(13)+' The email address ' +
> m_error,'Alert',64)
> endif
> endscan
> RETURN
>
>
>
>
> ENDCLASS
>
>


Pat Curran

2005-10-12, 11:24 am

Sure...I'll put something together for you and post it later on...What
version of visual dBase are you using?

Take Care
Pat


Rick

2005-10-12, 11:24 am

Pat,

Plus 2.21

Thanks again Pat,
Rick

Pat Curran Wrote:

> Sure...I'll put something together for you and post it later on...What
> version of visual dBase are you using?
>
> Take Care
> Pat
>
>


Linda C. Baker

2005-10-12, 11:24 am

I modified the code below and want to use it so that the user can automatically send me an email with .dbf files attached. It works great. I have Outlook 2003. What I want to know is will it work with most versions of Outlook? Also, is there an error
code or something that I can check so that when the code below runs and the user doesn't have Outlook installed, I can display a message saying they must have Outlook to run this program

Thanks.

Pat Curran Wrote:

> Hi Rick;
>
> I am happy that I can finally reply to a question on the group instead of
> always asking for help:-). Yes is is possible...I do it all the time with
> outlook 2003. Here is the code I use:
>
> m = new OLEAutoClient("Outlook.Application")
> item = m.CreateItem(0)
> item.recipients.Add(m_email)
> item.subject = "<Subject line text>"
> item.body = " <body of email>"
> item.display()
> *item.send()
> ShowApp("<Subject")
> return
>
> With the item.send() line removed, the message will open ready for you to
> type in the body and header. m_email is the variable for the email or you
> could also use a field from a table. You could also have your body or
> subject a variable or a field and adjust the lines as appropriate.
>
> If your ultimate goals is to send emails to multiple people automatically
> with out your user having to view the item and click send, you will need
> this freeware app to bypass outlooks security features. I will try to look
> for the file and get back to you on it.
>
> Pat
>
>
> "Rick" <Sportman7@netzero.net> wrote in message
> news:TiVNQl1yFHA.1412@news-server...
>
>


Bernd Hohenester

2005-10-12, 11:24 am

Hello Linda,

> I modified the code below and want to use it so that the user can automatically send me an email with .dbf files attached. It works great. I have Outlook 2003. What I want to know is will it

work with most versions of Outlook? Also, is there an error code or
something that I can check so that when the code below runs and the user
doesn't have Outlook installed, I can display a message saying they must
have Outlook to run this program


All you need are the file SendMail.cc from the dUFLP and the file
SendMaEx.cc from the binaries-newsgroup.

Then you start with:

set procedure to SendMaEx.cc additive
EmailMsg = new EmailEx()
EmailMsg.Dest = "username@domain.ext"
EmailMsg.Subject = "Title / Subject"
EmailMsg.Message = "Enter your message here..."
EmailMsg.Attachments.add("FileName1.ext")
EmailMsg.Send()
close procedure SendMaEx.cc

Its function send() first tries to send the e-mail with Outlook. If this
attempt leads to an error, Outlook Express is used.

cu
Bernd
Sponsored Links





Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive | Programming forum archive

Copyright 2008 droptable.com