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

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
just3082Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Bob LearnedCommented:
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
just3082Author Commented:
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
Bob LearnedCommented:
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
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

just3082Author Commented:
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
Bob LearnedCommented:
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
just3082Author Commented:
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
Bob LearnedCommented:
What is a typical value in txtMsg(0)?
0
just3082Author Commented:
Whatever the user types in as the problem that is occurring.

just3082
0
Bob LearnedCommented:
How does the ticket get created?  
0
just3082Author Commented:
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
Bob LearnedCommented:
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
just3082Author Commented:
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
Bob LearnedCommented:
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
just3082Author Commented:
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
Bob LearnedCommented:
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
just3082Author Commented:
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
Bob LearnedCommented:
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
just3082Author Commented:
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
just3082Author Commented:
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
Bob LearnedCommented:
From the article, the only line that you need is:

' The auto-number field is 0 before the requery.
objRS.Requery
0
just3082Author Commented:
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
Bob LearnedCommented:
What kind of recordset is ticket(9)?
0
just3082Author Commented:
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
Bob LearnedCommented:
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
just3082Author Commented:
No, Didn't work. Still getting C:\HelpDesk.exe 0


Just3082
0
Bob LearnedCommented:
What is TicketID?  A text box?  
0
just3082Author Commented:
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
just3082Author Commented:
Read Above
0
Bob LearnedCommented:
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
just3082Author Commented:
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
Bob LearnedCommented:
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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
just3082Author Commented:
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
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.