Link to home
Start Free TrialLog in
Avatar of spoowiz
spoowizFlag for United States of America

asked on

Need Complete Email Solution to either ShellExecute() or M$ Outlook Object Library or vbSendMail

This is a followup to the question in:
http://www-level3.experts-exchange.com/questions/20744815/Email-via-ShellExecute-send-automatic.html

After going thru it so far, I think I'd now rather have the "preview" mode where it doesn't send automatically (or at least have the option of previewing, without going thru another coding of a form to do the preview).

I still need an email solution.

vbSendMail
-------------------
While vbSendMail from vbfreecode.com works great, I don't see a way to see a history of what was sent (as in the Sent folder of outlook or outlook express). I feel this is a necessary. I suppose I can devise a method myself and then to learn how to pass values to vbSendMail (which I don't know yet). So unless there is a way to keep history, vbSendMail is not an option.

ShellExecute
--------------------
ShellExecute works now for me except for 2 things:
1. automatic send. I have to manually press "send" to send. (it uses my outlook express as the mail app).
Actually this is preferable for now. but I would like to have the option of sending automatically. But it is acceptable as is.
2. This is the deal killer. The email body somehow has a limit of approx 1950 chars. The mail doesn't even get composed if the body exceeds that number. This is a serious problem using ShellExecute.

M$ Outlook Object Library
----------------------
1. I just don't know how to use it.
In the accepted solution in the link above, it doesn't work because of error "user defined type not defined" and highlights:
Dim iOutlook As Outlook.Application
I don't know how to define it. Where can I learn more? More examples etc?
2. I'm concerned that this solution will not give me the option of "not sending automatically". i.e. composed email with everything filled out stays on the screen without being sent. Is there such an option?
p.s. I'm using outlook express, not outlook.

My inclination is that MS Outlook Object Library solution is probably the best solution if I can overcome my deficiencies.

I'm giving it 500 point value because you had to read thru all this mess :)

Thank you for reading and responding.
phil
Avatar of inthedark
inthedark
Flag of United Kingdom of Great Britain and Northern Ireland image

I would only think about using VBSendMail.  What you do is create an exe which runs in the background. (I created a Service but you don't have to.)

When you want to send a mail you write a simple class which saves your request into a simple text file which your write into a folder like:

C:\MAIL\MAILDROP\TEMP\mypaddress@mycontract.com mysubject.htm

When you have created the class moves your file into a folder like:

C:\MAIL\MAILDROP

Your listenning EXE wakes up every 30 seconds and checks to see if there are any files in C:\MAIL\MAILDROP.

If it finds a messages it moves it onto a folder:

C:\MAIL\PENDING

After if moves the file you create a temp file like:

C:\MAIL\MAILDROP\TEMP\mypaddress@mycontract.com mysubject.tmp

In the temp file you save the current time and the number of times you have tried to send this file.

Each time you try to send the file you modify the times sent and last send time also you can get the reason for the fail and save it into the temp file.  If you have not send the message after say 24 hours you forward it to the administrator.

If the message gets sent you delete the temp file and move the file to:

C:\MAIL\SentItems\mypaddress@mycontract.com mysubject.htm

I also drop the data into an Access database.

Most of the abopve is just saving and moving text files which is so easy in VB.

Name SourceFile as NewName

One more tip.  I created the text control file using HTML tags so that when you click on the file it looks better than an outlook message.  You imbed you data within a Font tag wich a specific name:

<Font Name="Subject" Style="Font-Size:12pt;color=Blue">My Email Subject</Font>

Etc.

So when you decode the file in order to prepare the message to be sent by vbsendmail its a very simple decoding job.

Hope this helps:~)

ASKER CERTIFIED SOLUTION
Avatar of Dirk Haest
Dirk Haest
Flag of Belgium 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
Avatar of spoowiz

ASKER

Wow! I can't get over this. You guys are incredibly fast and knowledgeable!

Inthedark,
I like the idea of using vbSendMail and love the design flow, but I'm not so experienced with VB to be able to confidently do it.  I wouldn't even know how to start. You don't happen to know where this code might be. I'm very good at copying :) I'd give mucho more points for that!!!

Dhaest,
Can I set it so the message DOES NOT get sent automatically?
I'll have to look at these examples etc and get back to you.

I'm not closing this solution just yet. Got to look at dhaest's solution more in depth and also see if Inthedark knows of any existing code that does what he proposes.

Thanks guys.
Avatar of spoowiz

ASKER

Altho Inthedark solution was appealing due to use of vbSendMail, I'm just not experienced enough to implement his suggested project.

Altho I couldn't get Dhaest's outlook code, the following link gave me everything I needed. Thanks

https://www.experts-exchange.com/questions/10195866/Mail-Program.html