hi for every one
i have program using to send e-mail but i want to attach text file with that
e-mail .
how attach text file with e-mail automatically ?
example :
every time send e-mail i want attach text file example : c:\xx.txt .
thank you .
3 2235
i use following program to send e-mail but i want to attach file with message : - Dim Response As String, Reply As Integer, DateNow As String
-
Dim first As String, Second As String, Third As String
-
Dim Fourth As String, Fifth As String, Sixth As String
-
Dim Seventh As String, Eighth As String
-
Dim Start As Single, Tmr As Single
-
-
-
-
Sub SendEmail(MailServerName As String, FromName As String, FromEmailAddress As String, ToName As String, ToEmailAddress As String, EmailSubject As String, EmailBodyOfMessage As String)
-
On Error Resume Next
-
Winsock1.LocalPort = 0 ' Must set local port to 0 (Zero) or you can only send 1 e-mail pre program start
-
-
If Winsock1.State = sckClosed Then ' Check to see if socet is closed
-
DateNow = Format(Date, "Ddd") & ", " & Format(Date, "dd Mmm YYYY") & " " & Format(Time, "hh:mm:ss") & "" & " -0600"
-
first = "mail from:" + Chr(32) + FromEmailAddress + vbCrLf ' Get who's sending E-Mail address
-
Second = "rcpt to:" + Chr(32) + ToEmailAddress + vbCrLf ' Get who mail is going to
-
Third = "Date:" + Chr(32) + DateNow + vbCrLf ' Date when being sent
-
Fourth = "From:" + Chr(32) + FromName + vbCrLf ' Who's Sending
-
Fifth = "To:" + Chr(32) + ToNametxt + vbCrLf ' Who it going to
-
Sixth = "Subject:" + Chr(32) + EmailSubject + vbCrLf ' Subject of E-Mail
-
Seventh = EmailBodyOfMessage + vbCrLf ' E-mail message body
-
Ninth = "X-Mailer: EBT Reporter v 2.x" + vbCrLf ' What program sent the e-mail, customize this
-
Eighth = Fourth + Third + Ninth + Fifth + Sixth ' Combine for proper SMTP sending
-
-
Winsock1.Protocol = sckTCPProtocol ' Set protocol for sending
-
Winsock1.RemoteHost = MailServerName ' Set the server address
-
Winsock1.RemotePort = 25 ' Set the SMTP Port
-
Winsock1.Connect ' Start connection
-
-
WaitFor ("220")
-
-
StatusTxt.Caption = "Connecting...."
-
StatusTxt.Refresh
-
-
Winsock1.SendData ("HELO worldcomputers.com" + vbCrLf)
-
-
WaitFor ("250")
-
-
StatusTxt.Caption = "Connected"
-
StatusTxt.Refresh
-
-
Winsock1.SendData (first)
-
-
StatusTxt.Caption = "Sending Message"
-
StatusTxt.Refresh
-
-
WaitFor ("250")
-
-
Winsock1.SendData (Second)
-
-
WaitFor ("250")
-
-
Winsock1.SendData ("data" + vbCrLf)
-
-
WaitFor ("354")
-
-
-
Winsock1.SendData (Eighth + vbCrLf)
-
Winsock1.SendData (Seventh + vbCrLf)
-
Winsock1.SendData ("." + vbCrLf)
-
-
WaitFor ("250")
-
-
Winsock1.SendData ("quit" + vbCrLf)
-
-
StatusTxt.Caption = "Disconnecting"
-
StatusTxt.Refresh
-
-
WaitFor ("221")
-
-
Winsock1.Close
-
Else
-
MsgBox (Str(Winsock1.State))
-
End If
-
-
End Sub
-
Sub WaitFor(ResponseCode As String)
-
On Error Resume Next
-
-
Start = Timer ' Time event so won't get stuck in loop
-
While Len(Response) = 0
-
Tmr = Start - Timer
-
DoEvents ' Let System keep checking for incoming response **IMPORTANT**
-
If Tmr > 50 Then ' Time in seconds to wait
-
MsgBox "SMTP service error, timed out while waiting for response", 64, MsgTitle
-
Exit Sub
-
End If
-
Wend
-
While Left(Response, 3) <> ResponseCode
-
DoEvents
-
If Tmr > 50 Then
-
MsgBox "SMTP service error, impromper response code. Code should have been: " + ResponseCode + " Code recieved: " + Response, 64, MsgTitle
-
Exit Sub
-
End If
-
Wend
-
Response = "" ' Sent response code to blank **IMPORTANT**
-
End Sub
-
-
-
Private Sub Command1_Click()
-
On Error Resume Next
-
-
SendEmail txtEmailServer.Text, txtFromName.Text, txtFromEmailAddress.Text, txtToEmailAddress.Text, txtToEmailAddress.Text, txtEmailSubject.Text, txtEmailBodyOfMessage.Text
-
'MsgBox ("Mail Sent")
-
StatusTxt.Caption = "Mail Sent"
-
StatusTxt.Refresh
-
-
Close
-
-
End Sub
-
-
Private Sub Command2_Click()
-
End
-
End Sub
-
-
-
Private Sub Winsock1_DataArrival(ByVal bytesTotal As Long)
-
-
On Error Resume Next
-
Winsock1.GetData Response ' Check for incoming response *IMPORTANT*
-
End Sub
Hi,
I have a function that we use to send email via Microsoft email outlook..might help you.
Function fnSendMail(strAttachmentFile, strToAddress, strSubject, strBody)
Set objOutlook = CreateObject("Outlook.Application")
Set objItem = objOutlook.CreateItem(0)
objItem.Attachments.Add strAttachmentFile
arrAddressArray = Split(strToAddress, ";")
strAddress = ""
For intAddCount = 0 To UBound(arrAddressArray)
If InStr(arrAddressArray(intAddCount), "@") <> 0 Then
If StrComp(strAddress, "") <> 0 Then
strAddress = strAddress & ";" & arrAddressArray(intAddCount)
Else
strAddress = arrAddressArray(intAddCount)
End If
End If
Next
objItem.To = strAddress
objItem.Subject = strSubject
objItem.Body = strBody
objItem.Display
objItem.Send
End Function
Hi,
I have a function that we use to send email via Microsoft email outlook..might help you.
Function fnSendMail(strAttachmentFile, strToAddress, strSubject, strBody)
Set objOutlook = CreateObject("Outlook.Application")
Set objItem = objOutlook.CreateItem(0)
objItem.Attachments.Add strAttachmentFile
arrAddressArray = Split(strToAddress, ";")
strAddress = ""
For intAddCount = 0 To UBound(arrAddressArray)
If InStr(arrAddressArray(intAddCount), "@") <> 0 Then
If StrComp(strAddress, "") <> 0 Then
strAddress = strAddress & ";" & arrAddressArray(intAddCount)
Else
strAddress = arrAddressArray(intAddCount)
End If
End If
Next
objItem.To = strAddress
objItem.Subject = strSubject
objItem.Body = strBody
objItem.Display
objItem.Send
End Function
thank you but i do not use outlook
i want to attach file with my program that posted in here .
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Aymer |
last post by:
i created a new button object. how do i attach an event
on it? thanx for your help.
Dim cc As ColorConverter = new ColorConverter()
Dim b = new button()
b.ID = "SelectedDate"
b.BorderStyle...
|
by: tabonni |
last post by:
Hi
I try to grab the checked files from HTML page and then send those PDF
files as attachments. It can just send email, there are no PDF files
attached. Can anybody point out my error?
My...
|
by: RickL |
last post by:
How do you attach a file to a hyperlink so that it cab be opened when clicked? I am new to .net and web development and I need to attach a file to an asp page so that when click it can be opened it...
|
by: kevcar40 |
last post by:
i have a form that i want to attach files to as hyperlinks
the problem is there could be upto 10 files attached to the form or
maybe none
How can i go about
1 creating the attachements and...
|
by: Greg P |
last post by:
I know this is a long post, please bear with me. I have been working on
this all weekend to no avail although I have done a good amount of research
(see most pertinent links that I've looked at...
|
by: calebmichaud |
last post by:
Hi
I am having trouble understanding how to attach a file or files to a
record. I want to (in form view0 allow the user to attach one or more
than one file to the associated record, and then...
|
by: Kees de Winter |
last post by:
Is it possible to attach the VS2005 debugger to an already running, and
published website? If I choose "Attach to process" from the menu and then
select the right process, set breakpoints, run the...
|
by: Lexxzy |
last post by:
Hi to all,
I've a problem about to attach a recovered database file in the enterprise manager.
My problem goes this way, I want to attach a recovered database file. So when I followed this...
|
by: sreemathy2000 |
last post by:
My requirement is to generate and attach a file and send in an email automatically.
i have a existing functionality where i using the code below to write a CSV file in my local system.
...
|
by: dpatel75 |
last post by:
I am trying to copy a database from a SQL 2000 SP3 Windows 2000 server
to a 2005 SP2 Windows 2003 server.
I am trying to use detach and attach method (have tried both within
Management Studio and...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
| |