How to write a client's email via vb6

We have several clients that are using different emails.  In our VB6 application, we are initiating their default email.  Once initiated, I need to write to the body of the email.

Would anyone know how to send text to the body of an email?  I.e., how do I access the body of the email so that I can write to it.  Are there properties?

We want to populate part of the email with subject, body, and addressees.  Does the code consist of something like "email.body = xyz" or "email.subject = test"?

If you can provide an example code or point me in the direction where I can obtain this information, I truly appreciated it.

Thank you.

CarmenMTorresAsked:
Who is Participating?
 
Brook BraswellConnect With a Mentor Application Development ManagerCommented:
The 3rd party tool does not write to the clients email but rather sends email via an SMTP.
You could look into it as I am sure it does more than I use it fore.
Just google up CodeStone and you are sure to find it.

Matter of fact...just try this

http://www.codestone.ltd.uk/


0
 
BardobraveCommented:
What app/object/control are you using to create the mail? Your problem's solution will depend on it, and probably the documentation of the app/object/control have all information you need.
0
 
Brook BraswellApplication Development ManagerCommented:
There are two ways to do this in VB6.
One way which calls the clients default email is to use a WebBrowser Control

add one to a form and name it WB

You use the MailTo parameters but you may have to convert your Subject and Body text to URL standards...

?subject=I like email
&body=this is the body of my mail

so that
WB.Navigate2 "MailTo:email@yourdomain.com?subject=I like email&body=this is the body of my mail"

Will open the default client and place "I like email" as the subject and "this is the body of my mail" in the body
0
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

 
Brook BraswellApplication Development ManagerCommented:
The other way is to have a 3rd party mail client like CodeStone.
This will allow you to send mail and control the body, subject, CC and BCC but it may not open a default mail client rather send silently through the SMTP server.
0
 
CarmenMTorresAuthor Commented:
I was trying to initiate the client's default email by reading the registry and executing the default email.  Once the email is opened, I was attempting to write to it, but was not successful.  (Please note that I am new to all this -- so I am most likely doing it incorrectly.)

I've been researching but the articles that I have come across are assuming that I am coding in .NET or html or asp - not VB6.  Examples of what the client email would be are Outlook, Lotus Notes, and GroupWise.

Is there a way of writing to an email that is opened?  Or am I approaching this incorrectly.

What I would like to do is:

(1) Determine the default email,
(2) Open the an email
(3) Write to the email - via code
(4) Mail email.

We cannot use a third party tool, so I have to write the code.

If it is possible to provide a clipping of the code or point me in the right direction, I would really appreciate it.

Thank you again.

0
 
Brook BraswellApplication Development ManagerCommented:
Steps 1, 2 and 3 are described in my initial response.
I do not know of a way to FORCE the email to go after it is open without possibly setting focus to that application and sending keystrokes.  But doing so would force you to KNOW what the default is and HOW to force the send.

If you want that total control then you may not want to go with using the default.
Then going that route you loose the ability to track sent mail within their default.
You could always use 3rd party controls and then create a record of the emails sent in your own database.

I personally use a mix of both of these methods in my applications where I want the app to send mail and the user does not care to track and I want total control then I use 3rd party.
If the user wishes more control on their side then use the webbrowser control and populate the necessary fields.  Then your users can change what they need or add to the body then send on their own.
0
 
CarmenMTorresAuthor Commented:
Brook1966, what do you mean by "you may have to convert your Subject and Body text to URL standards..."?  Can you provide an example?

Also, where can I get more information on the webbrowser control?  Does the webbrowser have the ability to communicate with any email?

We've decided to that we will initiate the client's email and populate the body, but the user will be in control of sending the email to the specified receipient.
0
 
Brook BraswellApplication Development ManagerCommented:
if your data contains special characters such as and Ampersand or a Hash/Number sign then you must replace these with URL equivalents:

& = %26
# = %23
? = %3F
+ = %2B

space = %20  <- not always necessary to monitor spaces
single quote ' = %27
double quote " = %22

so that the subject (A & B Company) and Body (Our #1 Priority is Fun + Work.  What is yours?)
would be sent as:
mailto:person@domain.com?subject=A %26 B Company&body=Our %231 Priority is Fun %2B Work.  What is yours%3F

Best Practice would be create a function perhaps like the example below

In your VB6 project, go to components and add the Microsoft Internet Controls ( shdocvw.dll )

I have not seen an Email app that this does not work with; However there are always exceptions.  I did have one of my clients with my internet app have problems with their customers when using the Notes mailing app.


Public Function SetURLText(byval S as string) as string
       s = Replace(S,"&","%26")
       s = Replace(S,"#","%23")
       s = Replace(S,"?","%3F")
       s = Replace(S,"+","%2B")
       s = Replace(S,"'","%27")
       s = Replace(S,chr(34),"%22")
       SetURLText = S
End Function

Open in new window

0
 
CarmenMTorresAuthor Commented:
Brook1966, would you have additional information on the 3rd Party mail client CodeStone?

We are now thinking of looking into getting a third party tool that might help us in activating the client's email and populating it with information before sending (mailing) it out.  We do not have the necessary expertise in house for coding an application with this functionality.
0
 
CarmenMTorresAuthor Commented:
Please give the points to Brook1966.  This author was most helpful with my issue.  Thank you.
0
All Courses

From novice to tech pro — start learning today.