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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Receiving an EMAIL without Outlook.

Status
Not open for further replies.

dkean4

Programmer
Feb 15, 2015
282
US
Is there a way without Outlook to receive Email, other than WestWind. I love Rick Strahl, absolutely great guy, but every time I change my PC I lose the registration to the Tools and I have to buy another one. This would be the 3rd time and I'm not doing it. This time I'm looking for an alternative.


TIA

Dennis


Simplicity is the extreme degree of sophistication.
Leonardo da Vinci
 
Simplest case: o = CreateObject("Outlook.Application"). With typical settings starting Outlook will receive mails.

You can read the inbox:
Code:
Local oOutlookObject,olNameSpace
#Define olFolderInBox 6
oOutlookObject = Createobject('Outlook.Application')
olNameSpace = oOutlookObject.GetNameSpace('MAPI')
oItems= olNameSpace.GetDefaultFolder(olFolderInBox).Items
For Each loItem In oItems
    If loItem.unRead 
       **Do something here
        loItem.unRead = .F. && Mark it as read
    Endif
Next

Taken from faq184-3894

Bye, Olaf.
 
Sorry, you said "without", my brain hurts. I read without outlook as with outlook, without looking closer, without luck.

Well, there still is MAPI and its inbox, sure there is some code to read the inbox the mapi way without the help of outlook items collections.

Code:
oMapiSession = Createobject("MSMAPI.MAPISession")
oMapiSession.DownLoadMail = .t.
oMapiSession.SignOn()

oMapiMessages = CREATEOBJECT("MSMAPI.MAPIMessages")
oMapiMessages.FetchUnreadOnly = .f.
oMapiMessages.SessionID = oMapiSession.SessionID
oMapiMessages.Fetch()
? oMapiMessages.MsgCount

FOR i = 0 TO oMapiMessages.MsgCount-1
    oMapiMessages.MsgIndex = i
    ? oMapiMessages.MsgSubject
ENDFOR

More at
Bye, Olaf.
 
Olaf,

In my Outlook I have a mixture of POP3 as well as MAPI Email accounts. I have about 15 accounts. Does anyone have Outlook these days with just one account? Using your 1st offering I cannot access the body of the Email, because it points me to the "Sent Box" and the default setting "#Define olFolderInBox 6" is wrong. That setting value 6 is for olFolderJournal not "olFolderInbox". Anyway I did figure out how to locate the Account I want to deal with "olNameSpace.Folders(14).Name" I have combed the hierarchy and discovered many things. One discovery is that each account defaults to "Sent To" rather than "InBox" and that is not affected by "olFolderInbox", though it might seem so. What would be nice would be a practical example of using this exceedingly general solution. And MS Developer Network is no help. I may as well start from scratch and build my own. Their jargon is not designed to help.

On your second offering, how could "oMapiMessages.Fetch()" be called at this stage when nothing was defined. The user Id, password, account name need to be entered. Clearly some abstruse setting somewhere down the two object's hierarchy will allow me to set it. But which, is the question. Again, MS Developer Network is nearly useless. So, while I appreciate the challenge to do my own digging, this has proven to be another MS round about path to the superlative abstruseness. (root word abstruse)

So, once again, to hell with MS and their retarded MAPI. Do you have any code using POP3, WITHOUT OUTLOOK, rather than MAPI, Olaf...?


Dennis Kean

Simplicity is the extreme degree of sophistication.
Leonardo da Vinci
 
I don't mind paying for ActiveX NigelGomm, but ActiveX bites back in many ways. If I buy anything I will once again buy Rick Strahl's version because he does a great job of simplifying it. However, I like to have a simple and independent compilation, where I do not have to worry about License issues, updates etc...

Thank you anyway.

Dennis Kean

Simplicity is the extreme degree of sophistication.
Leonardo da Vinci
 
>a mixture of POP3 as well as MAPI Email accounts
You get things confused here. MAPI is mail API and you surely talk of POP vs IMAP accounts, which means Internet Message Access Protocol. Both are controllable via MAPI, when you have multiple mail accounts, you have to figure out how to get at different inboxes, if you don't join them in one inbox/PST file anyway.

In regard of your question about Fetch, well, look at the SignOn portion, you can sign on to a certain account, but actually if you have multiple accounts in Outlook that most often still doesn't mean separate signons, it just means more folders besides the default/standard inbox. You don't have to signon with credentials via MAPI, as you onyl automate the mail client, it knows how to connect to the mail server, so you don't do that. Unless you want to program your own mail client, then you're on the level of implementing POP3 or IMAP protocols to connect to mailservers. If you like to do so, use a library like blat.

Bye, Olaf.
 
Olaf,

I meant IMAP. Getting old... It has been a while. Yes indeed, I would prefer to treat this particular account with POP3 separately.

And like I said, I did figure out how to get at the right account, "olNameSpace.Folders(14).Name"... but you also have to select the right directory InBox instead of the SendBox. The way it is Send Box is default, for whatever reason. If you have a working example on accessing all these elements, I would like to see it, but separate POP3 sound very appealing, right about now!



What is BLAT??

Dennis Kean

Simplicity is the extreme degree of sophistication.
Leonardo da Vinci
 
Just want to point out that getting a new computer shouldn't cost you your product registration. Have you communicated with Rick about it?

Tamar
 
It has been a while since I purchased it and I spoke to him once in 2003 to get a replacement, but he was quite averse to the idea. I understand that it means income to him, and now the product has evolved, so I don't want to press him. I have forgotten what it was called back when I bought it first. I looked at his site yesterday, and I do not recognize the names he has to start the discussion. But he has done a great job on his tools... always enjoyed his conciseness and clarity...

By the way, good to hear from you Tamar.... I was wondering how you were doing. I just ordered your book "Microsoft Office Automation with Visual FoxPro". (Second copy, I lost the first one... ha ha ha.) Does it come in download version? I could not find it on the WEB, so I ordered the paper version. I am open to the download version as well. Just tell me where to order it...

Very nice to hear from you, Tamar.


Dennis Kean

Simplicity is the extreme degree of sophistication.
Leonardo da Vinci
 
I just ordered your book "Microsoft Office Automation with Visual FoxPro". (Second copy, I lost the first one... ha ha ha.) Does it come in download version? I could not find it on the WEB, so I ordered the paper version.

Tamar can no doubt answer your question better than I can, but according to the Hentzenwerk site, that particular title is only available as an e-book (for US$29). There is evidently no paper version.

See But that page might be out of date (as other parts of the site seem to be).

Mike


__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
Thanks Mike, I saw that site yesterday, before I ordered the Paper book, which of course was a used version. That site is clearly not operational. I'm not waiting until any next February for a copy... Thank heavens for Amazon!


Dennis Kean

Simplicity is the extreme degree of sophistication.
Leonardo da Vinci
 
Dennis,

I don't know, but the code I gave as is lists my inbox mails from thunderbird.
What is blat? Well, google. It's listed among the 1 gazillion ways of how to send mails on the fox wiki.
But it doesn't only implement SMTP protocol for sending mails, it also implements POP3, eg see

Or more native with winsock:

I would not get that low level, though. You have a mail client installed, no matter what, and it knows how to receive and send mails. MAPI is the interface to it.

Bye, Olaf.
 
Olaf,

Sorry, i should have withdrawn the BLAT question. I looked it up. Interesting, but I need something much closer to VFP control.

Now, I already found and implemented the Berezniker. I got it working and it is very good. It is also very slow, probably because it was originally written for C++ and VFP cannot execute the intensive work that fast... I really don't know.

However, after debugging it, because it does not work as is, it delivers reliably every time. There were bad references to variables and problems of several sorts. But I worked at it for a few hours and it now works great, slow, but I can even delete the remote messages as I fetch them from the server. I seems steady so far and it is fully integrated into my application. So, once again you shine. Nothing good gets past Olaf.

However, I am very interested in making the MAPI version work for me. It would probably work faster and be much simpler with MAPI. I invite your help on that. Here is what I have done to it so far. I changed it a bit, imagining that it still has to have some bread crumbs to get at the enchilada.

Code:
oMapiSession = Createobject("MSMAPI.MAPISession")
oMapiSession.DownLoadMail = .t.
oMapiSession.UserName = "loco@dopalites.net"
oMapiSession.Password = "1234"
oMapiSession.SignOn()

oMapiMessages = CREATEOBJECT("MSMAPI.MAPIMessages")
oMapiMessages.FetchUnreadOnly = .f.
oMapiMessages.SessionID = oMapiSession.SessionID
oMapiMessages.Fetch()
? oMapiMessages.MsgCount

FOR i = 0 TO oMapiMessages.MsgCount-1
    oMapiMessages.MsgIndex = i
    ? oMapiMessages.MsgSubject
ENDFOR

the MsgCount is always 0. But the Objects are instantiated. There has to be some place where the domain is entered. The domain is clearly dopalites.net (bogus name).

Any ideas?



Dennis Kean

Simplicity is the extreme degree of sophistication.
Leonardo da Vinci
 
There is an e-version of the Automation book for download at the Hentzenwerke site. I'm not sure how that works when you buy a used book.

Tamar
 
Tamar,

I was not suggesting to get it for free... The book was only 10 dollars and they said it was very dirty in the ad. But it looks very nice to me.

I think that the site has not been operational for a while, Tamar.



Dennis Kean

Simplicity is the extreme degree of sophistication.
Leonardo da Vinci
 
You still misunderstand the MAPI code, it's not another version of doing the same as Bereznikers code, there is a HUGE difference.
1. Bereznikers code is logging into a mail server and receiving new messages, not yet downloaded, it is "slow", because alone the login into a mail server will take a bit. You don't use this to feed your mail client, you use this to create your own mail client. Do you really want to do that?
2. MAPI code is connecting to a mail client, which either has or has not loaded new mails. I don't know what doesn't work for you why, but did you try the original code with oMapiMessages.FetchUnreadOnly = .f.?

You should see all mails, if you don't set it the count most probably is 0 because all mails are read. Or because you don't have any mail client installed.

Bye, Olaf.

 
The sales portion of the Hentzenwerke site isn't working, but I think the rest is.

Tamar
 
Olaf,

Again, I have 6 domains and 14 Email boxes for which Outlook fetches Emails. I was not talking about domains/Email addresses for the purpose of logging into the remote Host Email server, but for the purpose of selecting the proper Email address list so I do not get every incoming Email from the 14 Email boxes.

Using your code I land on a "Sent to" box list, of an unknown 1 of 14 Email addresses. And of course it is going to be zero emails in it. So, I am thrilled that this code works for you, but it is a mystery to me why it does. I have scoured the hierarchy of the two objects and I find no way to set it to a specific InBox of the one Email address I want to get Emails for. In fact I cannot set it to any InBox. It always reaches to the "Sent To" box.

But let it rest, Olaf. I created a Berenziker based Email Server and it works outside of my App to get just the Email of the one Email address, as I desired. And it is very reliable so far. I love it because my App does not have to go into a lock-down every few minutes. It is just great. And I compared it to Outlook. Outlook takes time to load my Emails too. After some tuning, comparatively, Berizniker's version is less than twice slower, which is not bad. And I can delete the Emails from my Host as I load them. Thank you for the help. I could not be happier.





Dennis Kean

Simplicity is the extreme degree of sophistication.
Leonardo da Vinci
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top