Link to home
Start Free TrialLog in
Avatar of Apples01
Apples01

asked on

Visual Basic 6.0 email assistance requested please

Dear Expert,

The below code logs into our exchange server and successfully sends an email message. Using this same existing connection, is there something I can add so that it could loop thru all messages found on the strUser account and only count the ones in which the subject contains Alert?  Please help.

Set MyEmail = Nothing
Set MyEmail = CreateObject("CDO.Message")
MyEmail.Subject = "Subject"
MyEmail.TextBody = "Body"

MyEmail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
MyEmail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = strDomain
MyEmail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
MyEmail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 2
MyEmail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusername") = strUser
MyEmail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = strPassword
MyEmail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 100
MyEmail.Configuration.Fields.Update

MyEmail.Send

Set MyEmail = Nothing
Avatar of Robberbaron (robr)
Robberbaron (robr)
Flag of Australia image

yes but it only works for Exchange 2003 and earlier...  ExchangeOLEDB  & WebDAV.
https://msdn.microsoft.com/en-us/library/aa142634(v=exchg.65).aspx


i moved to C# for this reason, using Exchange Managed API/
could loop thru all messages found on the strUser account
So that suggests you want to POP the emails and process the emails. ASP might not be the best environment for building such an application. You actually need something that continues to run and monitor the strUser email account even when no users are browsing the ASP pages. In light of that, a Windows Service or a Command Line application scheduled in Windows Scheduler to run at intervals might be best.

Protocols
To check emails, there are a few options, and they depend on what is supported by your server. Sometimes. you IT can enable the alternatives. For an Exchange Server, there is the Exchange Web Services/ActiveSync/Managed API. The other email protocols are POP and IMAP. Classic ASP (AFAIK) does not have a native componnent for any of these protocols. You can go third party and find ActiveX controls that can do this (AfterLogis MailBee, EasyMail POP3 ( wonderful example for EasyMail here), SoftArtisans, and so on). These are examples of libraries that will do this from Classic ASP.

.NET
That said... I would agree with RobberBaron. C# might be easier... This has become a lot easier now, in the .NET world. There are open source options, and commercial options available. It will also be easier to write a windows service in .NET. I have used MailBee.NET for processing POP/IMAP + SMTP emails and I am very happy with it. For connecting to Exchange, I tried Aspose Email (but I ditched it in favour of the Exchange Managed API)
Avatar of Apples01
Apples01

ASKER

Thank you for the responses.  The strUser account is actually an account found on our exchange server (not a POP or IMAP  accont).  I tried connecting via IMAP using an Outlook profile stored on the pc and it does connect however it seems outlook needs to be running in order for the count to be a true real-time accurate count. Also this VB app is always running as service.  I am not sure how I would start and close outlook nicely so things do not get corrupted.  Please help.
The strUser account is actually an account found on our exchange server (not a POP or IMAP  accont).
Exchange can be configured to allow POP for example and you would be able to access the same account via POP.

IF you use the components I proposed earlier, then you don't need outlook because they are actually email clients themselves. Only without the GUI like Outlook does.

IF you want to rely on outlook, you can write an add-in which will get notified whenever outlook receives new mail. You could then do you prices in these events. http://www.slipstick.com/developer/processing-incoming-e-mails-with-macros/, https://msdn.microsoft.com/en-us/library/aa171304(v=office.11).aspx
IF you want to rely on outlook, you can write an add-in which will get notified whenever outlook receives new mail.

Yes, I would to rely on outlook and the exchange account that it has.

I'm sorry but doesn't outlook need to be started first in order for this add-in option to have current information?
Yes. Outlook would need to be open in order for that option to work.

For a Windows service scenario... Where you don't need outlook and the email checking happens even when no user is logged on then you need the exchange managed api or aspose.
Thank you. I will have to speak with our network administrator in regards to  exchange managed api or aspose.   In the meantime, does anyone know how to open and close outlook 2007 nicely using Visual Basic?
ASKER CERTIFIED SOLUTION
Avatar of Mlanda T
Mlanda T
Flag of South Africa image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial