|
-
Feb 14th, 2000, 06:23 AM
#1
Thread Starter
Addicted Member
I know I have done somthing wrong but I can't realy figure it out my self so i need your guys/Girls Help.
I get a error when using this code
Private Const mailserver As String = txtMailServ.Text
Private Const Tobox As String = txtToMail.Text
Private Const Frombox As String = txtFromMail.Text
Private Const Subject As String = txtSubject.Text
as you might notice I would get an error on the txtMailServ.text and the Other text boxses.
How can i make it so that I would not get a compile error ?
need more info about the project just ask.
Thanks.
-Lumin
-
Feb 14th, 2000, 06:46 AM
#2
Using mailserver as an example, do you really want it to be a constant? If so then you need to code it this way
Private Const mailserver = "My server Name"
If it should be a variable then
Private mailserver As String
mailserver = txtMailServ.Text
------------------
Marty
What did the fish say when it hit the concrete wall?
> > > > > "Dam!"
-
Feb 14th, 2000, 07:37 AM
#3
Thread Starter
Addicted Member
Thanks for the replay.
the second example you made didn't work and it was that one who looked like the one I want.
isn't there a way to to do it or do I ahve to rewrite the hole thing to get it to work?
-Lumin
-
Feb 14th, 2000, 12:12 PM
#4
Lively Member
lumin
a constant should always have a predetermined value, otherwise declare it as a variable.
Private mailserver As String
mailserver = txtMailServ.Text
like MartinLiss suggested.
-
Feb 15th, 2000, 06:39 AM
#5
Thread Starter
Addicted Member
ok. Thanks for the replay.
I only got 1 more question.
I tried declaring it as an variable, but I didn't get it to work.
(ye ye ye I know im stupid 
can someone help me, I think i may have done somthing wrong, so how do i declare somthing as an Variable?
Thanks.
-Lumin
------------------
Stupid as a Pencil
-
Feb 15th, 2000, 06:47 AM
#6
Thread Starter
Addicted Member
oh... stupid me...
I just found out what I did wrong...
well declaring it as an Variable didn't work, I also tried to declare it as an Variant but that didn't work to (dah big suprise).
So i got a problem here.
I want the users of my program to automaticly change the settings for the e-mail server subject and so on. but when declaring it as an string I have to preset those thing and I can't change them (unless someone know how to).
and when declaring them as Variable the program just won't send the eMails or the server just want them (I think its the first part.)
I have Included the Code so you can see whats wrong.
Code:
Option Explicit
Dim bTrans As Boolean
Dim m_iStage As Integer
'Private Const mailserver As String = "online.no"
'Private Const Tobox As String = "[email protected]"
'Private Const Frombox As String = "[email protected]"
'Private Const Subject As String = "test"
Private mailserver As String
Private Tobox As String
Private Frombox As String
Private Subject As String
'***************************************************************
'Routine for connecting to the server
'***************************************************************
Private Sub Connect_Click()
mailserver = txtMailServ.Text
Tobox = txtToMail.Text
Frombox = txtFromMail.Text
Subject = txtSubject.Text
If txtMailServ.Text = "" Then
MsgBox "ERROR: No Mail Server Selected", vbCritical, App.EXEName
If txtToMail.Text = "" Then
MsgBox "ERROR: No Reciver Selected", vbCritical, App.EXEName
Else
If Winsock1.State <> sckClosed Then Winsock1.Close
Winsock1.LocalPort = 0
Winsock1.Protocol = sckTCPProtocol
Winsock1.Connect mailserver, "25"
bTrans = True
m_iStage = 0
Transmit m_iStage
End If
End If
MsgBox "eMail was Sendt Sucsessfully", vbOKOnly, App.EXEName
End Sub
'***************************************************************
'Transmit the E-Mail
'***************************************************************
Private Sub Transmit(iStage As Integer)
mailserver = txtMailServ.Text
Tobox = txtToMail.Text
Frombox = txtFromMail.Text
Subject = txtSubject.Text
Dim Helo As String, temp As String
Dim pos As Integer
Select Case m_iStage
Case 1:
Helo = Frombox
pos = Len(Helo) - InStr(Helo, "@")
Helo = Right$(Helo, pos)
Winsock1.SendData "HELO " & Helo & vbCrLf
Case 2:
Winsock1.SendData "MAIL FROM: <" & Trim(Frombox) & ">" & vbCrLf
Case 3:
Winsock1.SendData "RCPT TO: <" & Trim(Tobox) & ">" & vbCrLf
Case 4:
Winsock1.SendData "DATA" & vbCrLf
Case 5:
temp = temp & "From: " & Frombox & vbNewLine
temp = temp & "To: " & Tobox & vbNewLine
temp = temp & "Subject: " & Subject & vbNewLine
'Header + Message
temp = temp & vbCrLf & txtMsgBody.Text
temp = temp & vbCrLf & vbCrLf & vbCrLf & "This eMail was Sendt to you by AES (Anonymus eMail Sender)" & vbCrLf & "v.1.0 by Lumin (http://home.sol.no/~lumin/)"
'Send the Message
Winsock1.SendData temp
Winsock1.SendData vbCrLf & "." & vbCrLf
m_iStage = 0
bTrans = False
End Select
End Sub
'***************************************************************
'Routine for Winsock Errors
'***************************************************************
Private Sub Winsock1_Error(ByVal number As Integer, Description As String, ByVal Scode As Long, ByVal Source As String, ByVal HelpFile As String, ByVal HelpContext As Long, CancelDisplay As Boolean)
MsgBox "Error:" & Description, vbOKOnly, "Winsock Error!" ' Show error message
If Winsock1.State <> sckClosed Then
Winsock1.Close
End If
End Sub
'***************************************************************
'Routine for arraving Data
'***************************************************************
Private Sub Winsock1_DataArrival(ByVal bytesTotal As Long)
Dim strData As String
On Error Resume Next
Winsock1.GetData strData, vbString
'txtStatus.Text = txtStatus.Text & strData
If bTrans Then
m_iStage = m_iStage + 1
Transmit m_iStage
Else
If Winsock1.State <> sckClosed Then Winsock1.Close
End If
End Sub
Private Sub Exit_Click()
On Error Resume Next
If Winsock1.State <> sckClosed Then Winsock1.Close
End
End Sub
Hope some one can help me.
Thanks anyway.
-Lumin
[This message has been edited by lumin (edited 02-15-2000).]
-
Feb 15th, 2000, 11:51 AM
#7
Lively Member
lumin,
i'm kinda slow in detecting errors in a such a long code and i know nothing about communication programs. maybe you could tell me what line makes the error and the error message and then maybe i could help.
-
Feb 15th, 2000, 12:51 PM
#8
Thread Starter
Addicted Member
Hi
Thanks for the replay.
ok actual there is no error i the program, but when using the code that goes from line 9-12 (those who are not greened out.) the program simply won't send the eMail but when using the predefined code line: 5-8 it works.
so my question was if anyone knew if I could replace line 5-8 with somthing that looked like 9-12 since 9-12 is configurable by the users while 5-8 ain't. confusing?
(I counted the numbers of lines begining with the Option Explicit line)
-Lumin
[This message has been edited by lumin (edited 02-16-2000).]
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|