Solved

Is there a way to e-mail a form from VS6 SP5

Posted on 2003-10-27
32
244 Views
Last Modified: 2013-12-25
I have a form that I want the contents to be sent via e-mail to an address on my internal network. The program I am working on is a Help Task database.

Using vbSendMail 3.65.

I am able to send e-mail succesfully, however I need to send all of the values in my controls
as well. For instance I have 8 different text fields that I need to be sent as well as a shortcut that the user receiving the e-mail can click on to open the main help task database or rather the form from my app. This way the tech receiving the ticket can click on the shortcut and be carried directly to the ticket in the database for editing purposes. As I said though I want them to be carried directly to my app to the help task section displaying the exact ticket that was in the subject of the e-mail. Hope this is clear. It sounds confusing to me... :)

Thanks in advance , just3082
0
Comment
Question by:just3082
  • 17
  • 15
32 Comments
 
LVL 96

Expert Comment

by:Bob Learned
Comment Utility
The data is stored in a shared location?  The E-Mail has a reference to a ticket record in the database?  When clicking on something in the E-Mail, the system would open a program, and view the ticket?

Is this even close to what you said?
0
 

Author Comment

by:just3082
Comment Utility
Yes, when the ticket is first created it is emailed to a technician. I need some sort of shortcut to be attached to the email so they can click on it and it open the app to the specified Ticket.

The ticket number is sent as the Subject in each message.

Thanks, just3082

0
 
LVL 96

Expert Comment

by:Bob Learned
Comment Utility
What do the technician's use an E-Mail client?  Outlook, Outlook Express?  If you are using Outlook, and they all have access to the same network drive, then you could put in the body of the message an entry like this:

<application path>\App.exe 32767.  Then the technician can click on the hyperlink and pass the ticket # as a command line parameter to the application.
0
 

Author Comment

by:just3082
Comment Utility
The ticket number would be different each time. I could create the first portion of it
but then would have to somehow append the ticket number to the command line parameter ??

Yes we are using Outlook 2000.

just3082
0
 
LVL 96

Expert Comment

by:Bob Learned
Comment Utility
Have you created any code for this project yet?  Are you just trying to figure out how to get this one thing done?

If the body has text like this:

C:\Apps\HelpDesk\HelpDesk.exe 32767, then the application HelpDesk will be run, and the 32767 will be passed to the application in the command line parameters.  For VB6 it could be accessed using the Command() function.
0
 

Author Comment

by:just3082
Comment Utility
I understand this, but somehow or another each time a new ticket is created I've got to get
the path along with the curretn ticket ID in the message body automatically. I don't want the user opening the ticket to have to manually type this each time.....

Right now, This is the code I have... Remember I am still a newbie....

Option Explicit
Option Compare Text
Private WithEvents poSendMail As vbSendMail.clsSendMail
Private Sub Command4_Click()
Unload Me
End Sub
' form load or module main sub…
Private Sub Form_Load()
 'initialize the component
Set poSendMail = New clsSendMail
'Combo7.Text = GetUserName
End Sub

' use a command button to send the message
Private Sub Send_Click()
'Assumes you have a form with text boxes named as below
poSendMail.SMTPHost = txtServer.Text
poSendMail.From = txtFrom.Text
'poSendMail.FromDisplayName = txtFromName.Text
poSendMail.Recipient = txtTo.Text
'poSendMail.RecipientDisplayName = txtToName.Text
'poSendMail.ReplyToAddress = txtFrom.Text
poSendMail.Subject = txtFields.Item(9).Text
poSendMail.Subject = txtFields.Item(1).Text
poSendMail.Attachment = txtFileName.Text
' file attachment(s), optional
poSendMail.Message = txtMsg(0)
poSendMail.Send
End Sub
Private Sub poSendMail_SendSuccesful()
    MsgBox ("Mail Sent OK!")
    End Sub
Private Sub poSendMail_SendFailed(Explanation As String)
MsgBox ("Mail Failed!" & vbCrLf & Explanation)
End Sub
Private Sub poSendMail_Status(Status As String)
LblStatus.Caption = Status
End Sub

Private Sub poSendMail_Progress(lPercentCompete As Long)

' your code here …
    pgBar.Value = lPercentCompete
End Sub

Public Property Get Attachment() As String
Public Property Let Attachment(ByVal NewValue As String)
End Sub
0
 
LVL 96

Expert Comment

by:Bob Learned
Comment Utility
What is a typical value in txtMsg(0)?
0
 

Author Comment

by:just3082
Comment Utility
Whatever the user types in as the problem that is occurring.

just3082
0
 
LVL 96

Expert Comment

by:Bob Learned
Comment Utility
How does the ticket get created?  
0
 

Author Comment

by:just3082
Comment Utility
The main form has several text controls, I.e username, location of problem,
description of problem, date and time, The ticket ID field is an autonumber
from my access 2K database, so when the user entering the ticket clicks on
submit trouble ticket, it updates the file adodc1.recordset.updatebatch AddAffectAll
then e-mails the main database and whatever tech name was choosen from the
assign to tech control. I've created the database just haven't added the code for it
yet. Trying to make sure I can pass this data like I want before I get any deeper...

Hope this is clear enough...

just3082
0
 
LVL 96

Expert Comment

by:Bob Learned
Comment Utility
Now, when the record gets created in the recordset, get the ticket ID value.  Add the text to the body of the message:

poSendMail.Message = "C:\Apps\HelpDesk\HelpDesk.exe " & ticketID & vbCrLf & VbCrLf & txtMsg(0)

When the technician gets the message there should be a clickable link in the E-Mail to run the application and pass the ticket ID in the command line parameters.

In the application, modify the code where the application is first started, and examine the Command() function for a valid number, and go to the ticket if it is a valid ID.
0
 

Author Comment

by:just3082
Comment Utility
When trying to compile the App I get an error message:

"Compile Error"
 argument not optional   and  "C:\HelpDesk.exe " & TicketID & vbCrLf & vbCrLf & txtMsg(0)
on this line the "TicketID" is highlighted....

/????

just3082
0
 
LVL 96

Expert Comment

by:Bob Learned
Comment Utility
Did you dimension a variable TicketID As Long (Dim TicketID As Long)?  This error message usually means that you have a function or property called TicketID.   You might want to rename the variable.
0
 

Author Comment

by:just3082
Comment Utility
Working now, However the only thing showing up in the message field is

c:\helpdesk 0

Went into the DB and there is a ticket ID of 23 was assigned.

Also get error message Multistep operation generated errors, check each status.
Didn't get it until I added
Adodc1.RecordSet.UpdateBatch AdAffectAll as the first line
under Private Sub Submit_Click  

But I have to update the access db before sending the E-mail otherwise an autonumber will
not be created, hence no ticket id.

Just3082






0
 
LVL 96

Expert Comment

by:Bob Learned
Comment Utility
Look at this Micro$oft article:

HOWTO: Return Record's Autonumber Value Inserted into Access DB
http://support.microsoft.com/default.aspx?scid=http://support.microsoft.com:80/support/kb/articles/Q221/9/31.asp&NoWebContent=1

Multistep errors are a nasty occurrence when working with ADO.  There are a couple of reasons for this.  What version of ADO are you using (2.5, 2.6, 2.7, or 2.8)?

Why UpdateBatch?  When did you do an AddNew operation?

You are making me work hard for my money!!!
0
 

Author Comment

by:just3082
Comment Utility
ADO 2.5

First code I got included this command for updating records, so I just stuck with what worked.

On form Load I added a new recordset with this code:

Adodc1.RecordSet.AddNew

That's what newbies are for... :)  I really do appreciate your patience....

Just3082
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 96

Expert Comment

by:Bob Learned
Comment Utility
Try upgrading to the latest version of MDAC (2.8) from Micro$oft's download site.  Also try doing just an Update instead of an UpdateBatch.
0
 

Author Comment

by:just3082
Comment Utility
Tried using just update, however it is looking for a field or value to come after update. What would be used to tell it to update that all fields in that record ?

In processing of downloading Mdac 2.8.. Will update accordingly..

just3082
0
 

Author Comment

by:just3082
Comment Utility
Ok, The update seemed to eliminate alot of my problems with refreshing the DB, etc...

Still getting the 0 atrribute instead of the Ticket number. I read the link you sent,
however it is too confusing because it uses an ASP example and I can relate the too.

It's hard enough just learning it this way much less trying to translate....

Sorry...just3082
0
 
LVL 96

Expert Comment

by:Bob Learned
Comment Utility
From the article, the only line that you need is:

' The auto-number field is 0 before the requery.
objRS.Requery
0
 

Author Comment

by:just3082
Comment Utility
added ticket(9).Requery,  However when I type in the . I do not have an option of requery to choose only refresh and that doesn't work either...

Just3082
0
 
LVL 96

Expert Comment

by:Bob Learned
Comment Utility
What kind of recordset is ticket(9)?
0
 

Author Comment

by:just3082
Comment Utility
I'm sorry I was thinking obj was referring to Object, I've changed it and here is what I have:

Private Sub Send_Click()
Dim rs As ADODB.Recordset
Set rs = New ADODB.Recordset
Combo3.Text = "Open"
rs.Requery       <<<<<<<<<<<<<<<<<<<<<<<<Is this where it should be ?
Adodc1.Recordset.Update    
Adodc1.Refresh                      <<<<<<<<<<<< Do I even need this if I use Requery ?
Adodc1.Recordset.MoveLast
'Assumes you have a form with text boxes named as below
poSendMail.SMTPHost = txtServer.Text
poSendMail.From = txtFrom.Text
poSendMail.Recipient = txtTo.Text
poSendMail.Subject = txtFields.Item(1).Text
poSendMail.Message = "C:\HelpDesk.exe " & TicketID & vbCrLf & vbCrLf & txtMsg(0)
poSendMail.Send
Unload Me
JMHTickets.Show
End Sub
0
 
LVL 96

Expert Comment

by:Bob Learned
Comment Utility
Private Sub Send_Click()
Dim rs As ADODB.Recordset
Set rs = New ADODB.Recordset
Combo3.Text = "Open"
Adodc1.Recordset.Update    
Adodc1.Recordset.Requery
Adodc1.Recordset.MoveLast
'Assumes you have a form with text boxes named as below
poSendMail.SMTPHost = txtServer.Text
poSendMail.From = txtFrom.Text
poSendMail.Recipient = txtTo.Text
poSendMail.Subject = txtFields.Item(1).Text
poSendMail.Message = "C:\HelpDesk.exe " & TicketID & vbCrLf & vbCrLf & txtMsg(0)
poSendMail.Send
Unload Me
JMHTickets.Show
End Sub
0
 

Author Comment

by:just3082
Comment Utility
No, Didn't work. Still getting C:\HelpDesk.exe 0


Just3082
0
 
LVL 96

Expert Comment

by:Bob Learned
Comment Utility
What is TicketID?  A text box?  
0
 

Author Comment

by:just3082
Comment Utility
poSendMail.Message = "C:\HelpDesk.exe " & TicketID & vbCrLf & vbCrLf & txtMsg(0)

Is "TicketID suppose to be the control name or the field in my database's name ?

i.e Tickets.txt is the control name and the Field name in my DB is TicketID.

just3082
0
 

Author Comment

by:just3082
Comment Utility
Read Above
0
 
LVL 96

Expert Comment

by:Bob Learned
Comment Utility
It has to evaluate to a field value from the recordset.  Since you don't have a compile error, and TicketID = 0, then I would guess that you have a variable dimensioned as TicketID.

Try this:

poSendMail.Message = "C:\HelpDesk.exe " & Adodc1.Recordset!TicketID & vbCrLf & vbCrLf & txtMsg(0)
0
 

Author Comment

by:just3082
Comment Utility
This worked, however it doesn't link back to my application from e-mail.

I can click on the link and it opens my app, but doesn't open the specific ticket number.

Is that something I 'm going to have to live with  ?

I really really appreciate the time and effort you've extended.

Just3082
0
 
LVL 96

Accepted Solution

by:
Bob Learned earned 250 total points
Comment Utility
Did you put any code in the application to look at the command parameter passed in?  You need something like:

Form_Load:

   If Len(Command) > 0 Then
       DisplayTicket CLng(Command)
   Endif

   Private Sub DisplayTicket(ByVal TicketID As Long)

       ' Put code here to display the appropriate ticket.

   End Sub
0
 

Author Comment

by:just3082
Comment Utility
I'll go ahead and create a new task for this one. You've worked hard enough on this one.

Thanks again for all of your help...

just3082
0

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now