Grabbing an email Address from a Form  
Author Message
alvinzc





PostPosted: Fri Mar 18 15:29:02 CST 2005 Top

Exchange Servers >> Grabbing an email Address from a Form

hello, i am fairly new to all this. i have a contact form in a app we have. i
want to grab the email address from the form and open up Outlook, have the
address already in the .to and outlook just waiting for the user to input
something in the Body and to send it. currently my code goes some of the way
but not all.

oOutlook = createobject("Outlook.Application")
#Define olFolderdisplaynormal 0
oNameSpace = oOutlook.GetNameSpace("MAPI")
oExplorer = oOutlook.Explorers.add (oNameSpace.Folders[1],
olFolderDisplayNormal)
oExplorer.Activate()
#define olMailItem 0
oMailitem = oOutlook.createitem(olMailitem)
WITH oMailitem
.subject = "This is my Test Button"
.to = ("what do i put here??? ")
endwith
oMailItem.save()

i have tried the _miscbtn class in vfp6 and it does it, only it places the
entire form contents in the Body of the message. its easy to pull addresses
from the contacts folder but i cant from my form.
thank you in advance for your help.
Tom

Exchange Server33  
 
 
Tom





PostPosted: Fri Mar 18 15:29:02 CST 2005 Top

Exchange Servers >> Grabbing an email Address from a Form aOk i answered my own question with the Following Code.

oOutlook = createobject("Outlook.Application")
#define olMailItem 0
oMailitem = oOutlook.createitem(olMailitem)
WITH oMailitem
.to = lagstat.pemail
endwith
oMailitem.display

However it raised another. when a person sends in the above code, and
outlook is not open, it waits to actually send the item untill they open up
outlook. i need the mails to send when the user hits the send button, even if
Outllok is Closed.

Thanks again.
 
 
David





PostPosted: Sun Mar 20 11:45:59 CST 2005 Top

Exchange Servers >> Grabbing an email Address from a Form Tom,

Check Outlook to see if it has a Send Immediately flag. I know that Outlook
Express has this option and it controls whether or not the send happens
instantly or is delayed until the next send/recieve pass is made.

--
df - Microsoft MVP FoxPro http://www.geocities.com/df_foxpro



> aOk i answered my own question with the Following Code.
>
> oOutlook = createobject("Outlook.Application")
> #define olMailItem 0
> oMailitem = oOutlook.createitem(olMailitem)
> WITH oMailitem
> .to = lagstat.pemail
> endwith
> oMailitem.display
>
> However it raised another. when a person sends in the above code, and
> outlook is not open, it waits to actually send the item untill they open
> up
> outlook. i need the mails to send when the user hits the send button, even
> if
> Outllok is Closed.
>
> Thanks again.


 
 
Paul





PostPosted: Sun Mar 20 23:08:47 CST 2005 Top

Exchange Servers >> Grabbing an email Address from a Form I think with the newer versions of Outlook, it's no longer possible to tell
it to Send, even if Outlook is running. You have to get the user to click
the Send button on Outlook. Someone tell me if I'm wrong.

I think this was done for security reasons - there were too many viruses &
such hijacking Outlook and sending emails without the users consent.






> aOk i answered my own question with the Following Code.
>
> oOutlook = createobject("Outlook.Application")
> #define olMailItem 0
> oMailitem = oOutlook.createitem(olMailitem)
> WITH oMailitem
> .to = lagstat.pemail
> endwith
> oMailitem.display
>
> However it raised another. when a person sends in the above code, and
> outlook is not open, it waits to actually send the item untill they open
> up
> outlook. i need the mails to send when the user hits the send button, even
> if
> Outllok is Closed.
>
> Thanks again.


 
 
Fred





PostPosted: Sun Mar 20 23:36:10 CST 2005 Top

Exchange Servers >> Grabbing an email Address from a Form I don't think you have to press "Send", but you do have to click "OK", that
someother program is trying to send mail. You can't do it undetected behind
the scenes anymore, at least not since Office 2K/Sp2?

--
Fred
Microsoft Visual FoxPro MVP




>I think with the newer versions of Outlook, it's no longer possible to tell
>it to Send, even if Outlook is running. You have to get the user to click
>the Send button on Outlook. Someone tell me if I'm wrong.
>
> I think this was done for security reasons - there were too many viruses &
> such hijacking Outlook and sending emails without the users consent.
>
>
>
>


>> aOk i answered my own question with the Following Code.
>>
>> oOutlook = createobject("Outlook.Application")
>> #define olMailItem 0
>> oMailitem = oOutlook.createitem(olMailitem)
>> WITH oMailitem
>> .to = lagstat.pemail
>> endwith
>> oMailitem.display
>>
>> However it raised another. when a person sends in the above code, and
>> outlook is not open, it waits to actually send the item untill they open
>> up
>> outlook. i need the mails to send when the user hits the send button,
>> even if
>> Outllok is Closed.
>>
>> Thanks again.
>
>


 
 
Tom





PostPosted: Mon Mar 21 09:25:02 CST 2005 Top

Exchange Servers >> Grabbing an email Address from a Form using the .send() will send it right away, However it continues to send
messages while you are typing in the Body.

so i have to use the .display, and the user clicks on send, if outlook is
closed the message goes to the outbox and waits until they open it. thats the
problem.

what about this, if Outlook is closed should i open it and leave it open?
right now if its open, i create anothe instance of it then close it when im
done. is there no way to set some of the advanced e-mail props from code?

thanks again

Tom




> I don't think you have to press "Send", but you do have to click "OK", that
> someother program is trying to send mail. You can't do it undetected behind
> the scenes anymore, at least not since Office 2K/Sp2?
>
> --
> Fred
> Microsoft Visual FoxPro MVP
>
>


> >I think with the newer versions of Outlook, it's no longer possible to tell
> >it to Send, even if Outlook is running. You have to get the user to click
> >the Send button on Outlook. Someone tell me if I'm wrong.
> >
> > I think this was done for security reasons - there were too many viruses &
> > such hijacking Outlook and sending emails without the users consent.
> >
> >
> >
> >


> >> aOk i answered my own question with the Following Code.
> >>
> >> oOutlook = createobject("Outlook.Application")
> >> #define olMailItem 0
> >> oMailitem = oOutlook.createitem(olMailitem)
> >> WITH oMailitem
> >> .to = lagstat.pemail
> >> endwith
> >> oMailitem.display
> >>
> >> However it raised another. when a person sends in the above code, and
> >> outlook is not open, it waits to actually send the item untill they open
> >> up
> >> outlook. i need the mails to send when the user hits the send button,
> >> even if
> >> Outllok is Closed.
> >>
> >> Thanks again.
> >
> >
>
>
>
 
 
Tom





PostPosted: Mon Mar 21 09:31:09 CST 2005 Top

Exchange Servers >> Grabbing an email Address from a Form One other question, how can i ensure that the text entered is a valid e-mail.





> using the .send() will send it right away, However it continues to send
> messages while you are typing in the Body.
>
> so i have to use the .display, and the user clicks on send, if outlook is
> closed the message goes to the outbox and waits until they open it. thats the
> problem.
>
> what about this, if Outlook is closed should i open it and leave it open?
> right now if its open, i create anothe instance of it then close it when im
> done. is there no way to set some of the advanced e-mail props from code?
>
> thanks again
>
> Tom
>
>

>
> > I don't think you have to press "Send", but you do have to click "OK", that
> > someother program is trying to send mail. You can't do it undetected behind
> > the scenes anymore, at least not since Office 2K/Sp2?
> >
> > --
> > Fred
> > Microsoft Visual FoxPro MVP
> >
> >


> > >I think with the newer versions of Outlook, it's no longer possible to tell
> > >it to Send, even if Outlook is running. You have to get the user to click
> > >the Send button on Outlook. Someone tell me if I'm wrong.
> > >
> > > I think this was done for security reasons - there were too many viruses &
> > > such hijacking Outlook and sending emails without the users consent.
> > >
> > >
> > >
> > >


> > >> aOk i answered my own question with the Following Code.
> > >>
> > >> oOutlook = createobject("Outlook.Application")
> > >> #define olMailItem 0
> > >> oMailitem = oOutlook.createitem(olMailitem)
> > >> WITH oMailitem
> > >> .to = lagstat.pemail
> > >> endwith
> > >> oMailitem.display
> > >>
> > >> However it raised another. when a person sends in the above code, and
> > >> outlook is not open, it waits to actually send the item untill they open
> > >> up
> > >> outlook. i need the mails to send when the user hits the send button,
> > >> even if
> > >> Outllok is Closed.
> > >>
> > >> Thanks again.
> > >
> > >
> >
> >
> >
 
 
Fred





PostPosted: Mon Mar 21 15:20:33 CST 2005 Top

Exchange Servers >> Grabbing an email Address from a Form This is the code I use:

olMailItem = 0
oOutLookObject = CreateObject("Outlook.Application")
oEmailItem = oOutLookObject.CreateItem(olMailItem)
With oEmailItem



.Attachments.Add("c:\somefile.txt")
.Subject = "This is the Subject"
.Send()
ENDWITH
oOutLookObject=null


--
Fred
Microsoft Visual FoxPro MVP




> using the .send() will send it right away, However it continues to send
> messages while you are typing in the Body.
>
> so i have to use the .display, and the user clicks on send, if outlook is
> closed the message goes to the outbox and waits until they open it. thats
> the
> problem.
>
> what about this, if Outlook is closed should i open it and leave it open?
> right now if its open, i create anothe instance of it then close it when
> im
> done. is there no way to set some of the advanced e-mail props from code?
>
> thanks again
>
> Tom
>
>

>
>> I don't think you have to press "Send", but you do have to click "OK",
>> that
>> someother program is trying to send mail. You can't do it undetected
>> behind
>> the scenes anymore, at least not since Office 2K/Sp2?
>>
>> --
>> Fred
>> Microsoft Visual FoxPro MVP
>>
>>


>> >I think with the newer versions of Outlook, it's no longer possible to
>> >tell
>> >it to Send, even if Outlook is running. You have to get the user to
>> >click
>> >the Send button on Outlook. Someone tell me if I'm wrong.
>> >
>> > I think this was done for security reasons - there were too many
>> > viruses &
>> > such hijacking Outlook and sending emails without the users consent.
>> >
>> >
>> >
>> >


>> >> aOk i answered my own question with the Following Code.
>> >>
>> >> oOutlook = createobject("Outlook.Application")
>> >> #define olMailItem 0
>> >> oMailitem = oOutlook.createitem(olMailitem)
>> >> WITH oMailitem
>> >> .to = lagstat.pemail
>> >> endwith
>> >> oMailitem.display
>> >>
>> >> However it raised another. when a person sends in the above code, and
>> >> outlook is not open, it waits to actually send the item untill they
>> >> open
>> >> up
>> >> outlook. i need the mails to send when the user hits the send button,
>> >> even if
>> >> Outllok is Closed.
>> >>
>> >> Thanks again.
>> >
>> >
>>
>>
>>


 
 
TonySper





PostPosted: Tue Mar 22 18:45:30 CST 2005 Top

Exchange Servers >> Grabbing an email Address from a Form Fred,
Is it possible to use variables for the TO, CC, BCC, and
Attachments.Add???
Maybe even a field in a database like tryit.email would be the email
address
Would you need an absolute location for the text file??
TonySper



This is the code I use:

olMailItem = 0
oOutLookObject = CreateObject("Outlook.Application")
oEmailItem = oOutLookObject.CreateItem(olMailItem)
With oEmailItem



.Attachments.Add("c:\somefile.txt")
.Subject = "This is the Subject"
.Send()
ENDWITH
oOutLookObject=null


--
Fred
Microsoft Visual FoxPro MVP




> using the .send() will send it right away, However it continues to
> send
> messages while you are typing in the Body.
>
> so i have to use the .display, and the user clicks on send, if
> outlook is
> closed the message goes to the outbox and waits until they open it.
> thats
> the
> problem.
>
> what about this, if Outlook is closed should i open it and leave it
> open?
> right now if its open, i create anothe instance of it then close it
> when
> im
> done. is there no way to set some of the advanced e-mail props from
> code?
>
> thanks again
>
> Tom
>
>

>
>> I don't think you have to press "Send", but you do have to click
>> "OK",
>> that
>> someother program is trying to send mail. You can't do it
>> undetected
>> behind
>> the scenes anymore, at least not since Office 2K/Sp2?
>>
>> --
>> Fred
>> Microsoft Visual FoxPro MVP
>>
>>


>> >I think with the newer versions of Outlook, it's no longer
>> >possible to
>> >tell
>> >it to Send, even if Outlook is running. You have to get the user
>> >to
>> >click
>> >the Send button on Outlook. Someone tell me if I'm wrong.
>> >
>> > I think this was done for security reasons - there were too many
>> > viruses &
>> > such hijacking Outlook and sending emails without the users
>> > consent.
>> >
>> >
>> >
>> >


>> >> aOk i answered my own question with the Following Code.
>> >>
>> >> oOutlook = createobject("Outlook.Application")
>> >> #define olMailItem 0
>> >> oMailitem = oOutlook.createitem(olMailitem)
>> >> WITH oMailitem
>> >> .to = lagstat.pemail
>> >> endwith
>> >> oMailitem.display
>> >>
>> >> However it raised another. when a person sends in the above
>> >> code, and
>> >> outlook is not open, it waits to actually send the item untill
>> >> they
>> >> open
>> >> up
>> >> outlook. i need the mails to send when the user hits the send
>> >> button,
>> >> even if
>> >> Outllok is Closed.
>> >>
>> >> Thanks again.
>> >
>> >
>>
>>
>>



 
 
Fred





PostPosted: Tue Mar 22 19:28:09 CST 2005 Top

Exchange Servers >> Grabbing an email Address from a Form Yes, you can use variables for any of the property values. You need to
provide a full path to the file as it's not going to know anything about
your current settings in VFP, because essentially, you're no longer running
in VFP when it tries to add the attachement. It's got to know how/where to
find the file completely on it's own.

--
Fred
Microsoft Visual FoxPro MVP




> Fred,
> Is it possible to use variables for the TO, CC, BCC, and
> Attachments.Add???
> Maybe even a field in a database like tryit.email would be the email
> address
> Would you need an absolute location for the text file??
> TonySper
>


> This is the code I use:
>
> olMailItem = 0
> oOutLookObject = CreateObject("Outlook.Application")
> oEmailItem = oOutLookObject.CreateItem(olMailItem)
> With oEmailItem



> .Attachments.Add("c:\somefile.txt")
> .Subject = "This is the Subject"
> .Send()
> ENDWITH
> oOutLookObject=null
>
>
> --
> Fred
> Microsoft Visual FoxPro MVP
>
>


>> using the .send() will send it right away, However it continues to
>> send
>> messages while you are typing in the Body.
>>
>> so i have to use the .display, and the user clicks on send, if
>> outlook is
>> closed the message goes to the outbox and waits until they open it.
>> thats
>> the
>> problem.
>>
>> what about this, if Outlook is closed should i open it and leave it
>> open?
>> right now if its open, i create anothe instance of it then close it
>> when
>> im
>> done. is there no way to set some of the advanced e-mail props from
>> code?
>>
>> thanks again
>>
>> Tom
>>
>>

>>
>>> I don't think you have to press "Send", but you do have to click
>>> "OK",
>>> that
>>> someother program is trying to send mail. You can't do it
>>> undetected
>>> behind
>>> the scenes anymore, at least not since Office 2K/Sp2?
>>>
>>> --
>>> Fred
>>> Microsoft Visual FoxPro MVP
>>>
>>>


>>> >I think with the newer versions of Outlook, it's no longer
>>> >possible to
>>> >tell
>>> >it to Send, even if Outlook is running. You have to get the user
>>> >to
>>> >click
>>> >the Send button on Outlook. Someone tell me if I'm wrong.
>>> >
>>> > I think this was done for security reasons - there were too many
>>> > viruses &
>>> > such hijacking Outlook and sending emails without the users
>>> > consent.
>>> >
>>> >
>>> >
>>> >


>>> >> aOk i answered my own question with the Following Code.
>>> >>
>>> >> oOutlook = createobject("Outlook.Application")
>>> >> #define olMailItem 0
>>> >> oMailitem = oOutlook.createitem(olMailitem)
>>> >> WITH oMailitem
>>> >> .to = lagstat.pemail
>>> >> endwith
>>> >> oMailitem.display
>>> >>
>>> >> However it raised another. when a person sends in the above
>>> >> code, and
>>> >> outlook is not open, it waits to actually send the item untill
>>> >> they
>>> >> open
>>> >> up
>>> >> outlook. i need the mails to send when the user hits the send
>>> >> button,
>>> >> even if
>>> >> Outllok is Closed.
>>> >>
>>> >> Thanks again.
>>> >
>>> >
>>>
>>>
>>>
>
>
>


 
 
TonySper





PostPosted: Wed Mar 23 11:47:50 CST 2005 Top

Exchange Servers >> Grabbing an email Address from a Form Fred,
Thanks. I will play around with it and see what I can do. I understand
about having to give the full path to the file. I guess what I have to
do then is to always send the file with a fixed name to the same
folder before I call up the email.
TonySper



Yes, you can use variables for any of the property values. You need
to
provide a full path to the file as it's not going to know anything
about
your current settings in VFP, because essentially, you're no longer
running
in VFP when it tries to add the attachement. It's got to know
how/where to
find the file completely on it's own.

--
Fred
Microsoft Visual FoxPro MVP




> Fred,
> Is it possible to use variables for the TO, CC, BCC, and
> Attachments.Add???
> Maybe even a field in a database like tryit.email would be the email
> address
> Would you need an absolute location for the text file??
> TonySper
>


> This is the code I use:
>
> olMailItem = 0
> oOutLookObject = CreateObject("Outlook.Application")
> oEmailItem = oOutLookObject.CreateItem(olMailItem)
> With oEmailItem



> .Attachments.Add("c:\somefile.txt")
> .Subject = "This is the Subject"
> .Send()
> ENDWITH
> oOutLookObject=null
>
>
> --
> Fred
> Microsoft Visual FoxPro MVP
>
>


>> using the .send() will send it right away, However it continues to
>> send
>> messages while you are typing in the Body.
>>
>> so i have to use the .display, and the user clicks on send, if
>> outlook is
>> closed the message goes to the outbox and waits until they open it.
>> thats
>> the
>> problem.
>>
>> what about this, if Outlook is closed should i open it and leave it
>> open?
>> right now if its open, i create anothe instance of it then close it
>> when
>> im
>> done. is there no way to set some of the advanced e-mail props from
>> code?
>>
>> thanks again
>>
>> Tom
>>
>>

>>
>>> I don't think you have to press "Send", but you do have to click
>>> "OK",
>>> that
>>> someother program is trying to send mail. You can't do it
>>> undetected
>>> behind
>>> the scenes anymore, at least not since Office 2K/Sp2?
>>>
>>> --
>>> Fred
>>> Microsoft Visual FoxPro MVP
>>>
>>>


>>> >I think with the newer versions of Outlook, it's no longer
>>> >possible to
>>> >tell
>>> >it to Send, even if Outlook is running. You have to get the user
>>> >to
>>> >click
>>> >the Send button on Outlook. Someone tell me if I'm wrong.
>>> >
>>> > I think this was done for security reasons - there were too many
>>> > viruses &
>>> > such hijacking Outlook and sending emails without the users
>>> > consent.
>>> >
>>> >
>>> >
>>> >


>>> >> aOk i answered my own question with the Following Code.
>>> >>
>>> >> oOutlook = createobject("Outlook.Application")
>>> >> #define olMailItem 0
>>> >> oMailitem = oOutlook.createitem(olMailitem)
>>> >> WITH oMailitem
>>> >> .to = lagstat.pemail
>>> >> endwith
>>> >> oMailitem.display
>>> >>
>>> >> However it raised another. when a person sends in the above
>>> >> code, and
>>> >> outlook is not open, it waits to actually send the item untill
>>> >> they
>>> >> open
>>> >> up
>>> >> outlook. i need the mails to send when the user hits the send
>>> >> button,
>>> >> even if
>>> >> Outllok is Closed.
>>> >>
>>> >> Thanks again.
>>> >
>>> >
>>>
>>>
>>>
>
>
>