Hi all
I want to know how to send a textfile to my e-mail is this possible?
Already Thx
~NitroAfg:thumb:
Printable View
Hi all
I want to know how to send a textfile to my e-mail is this possible?
Already Thx
~NitroAfg:thumb:
Here's some code I used.....prolly can be modified to send your textfile via smtp. Your email server must be configed to accept smtp traffic (I've only used this to send email to the email server on my network...not an isp-based one).
Public Function Sendemail(ByVal subject As String, ByVal senderid As String, ByVal mailto As String)
Try
Try
Dim Message As New MailMessage
Message.To = (mailto)
Message.From = (senderid)
Message.Subject = subject
Message.Body = "text of message"
Try
SmtpMail.SmtpServer = "Servernamehere"
SmtpMail.Send(Message)
Catch ehttp As System.Web.HttpException
'Console.WriteLine("0", ehttp.Message)
'Console.WriteLine("Here is the full error message")
'Console.Write("0", ehttp.ToString())
End Try
Catch e As IndexOutOfRangeException
' Display usage instructions if error in arguments.
'Dim use As usage = New usage
'use.DisplayUsage()
End Try
Catch e As System.Exception
' Display text of unknown error.
'Console.WriteLine("Unknown Exception occurred 0", e.Message)
'Console.WriteLine("Here is the Full Error Message")
'Console.WriteLine("0", e.ToString())
End Try
End Function
Thx but can you make an example of that
smtp.uwp.edu
it kind of is an example based on the variable names used ...sorry for the lack of indention though. substitute smt.uwp.edu for "Severnamehere". I took out some debugging code that I apparently left in....sorry.
OK... you should really try to figure things out yourself before just asking for someone to give you a fully working example, but here is something that should help you out. I havent tested it so it may need modifying slightly to get it to work.
vb Code:
Dim mysmtpclient As System.Net.Mail.SmtpClient Dim mymail As System.Net.Mail.MailMessage mysmtpclient = New System.Net.Mail.SmtpClient mymail = New System.Net.Mail.MailMessage mysmtpclient.Host = "smtp.uwp.edu" mysmtpclient.Credentials = New Net.NetworkCredential("USERNAME", "PASSWORD") mysmtpclient.Port = 25 mymail.From = New System.Net.Mail.MailAddress("[email protected]") mymail.To.Add(New System.Net.Mail.MailAddress("[email protected]")) mymail.Attachments.Add(New System.Net.Mail.Attachment("c:\pathtotextfilehere.txt")) mymail.Subject = "Subject Here" mysmtpclient.Send(mymail)
All you should need to do is modify the username and password that get used and modify the path to the text file that you want to attach. You also need to change the To and From address. It should be fairly obvious where to do this.
Oh and you can import the System.Net.Mail namespace to save having to type it out each time like I did.
Hope that helps.
Hi,Quote:
Originally Posted by Nitroafg
If you mean that you want to sent an attachment (textfile) with your E mail application then see post #10 in this thread.
http://www.vbforums.com/showthread.p...04#post3274804
Hope it helps,
sparrow1
[QUOTE
mysmtpclient.Credentials = New Net.NetworkCredential("USERNAME", "PASSWORD")
[/QUOTE]
What do you mean with Username Password my e-mails username and pass or something else ?
BTW I want to send the e-mail to live (hotmail)
The username and password that is required to send emails through the smtp server you mentioned (smtp.uwp.edu). Its possible that this email server doesnt require a username and password but its unlikely. Where did you get this smtp server address from? I mean I assume its the server that you normally send emails through so you should have a username and password set in Outlook (or whatever email program you are using to send emails through that smtp server).
Sorry I thought that smtp.uwp.edu was the hotmail (live) smtp but I found the real one its smpt.live.comQuote:
Originally Posted by chris128
do you know the pass and username :P
thx
I think your going about this all wrong. You dont have to use the hotmail server to send an email to a hotmail account... you can use any SMTP server that you have access to for this, typically it would be your company's email server or your ISP (internet service provider) email server.
I assume its possible to connect to the smtp.live.com server and use it to send email using your normal hotmail username and password but I've never tried so cant confirm that.
All kinds of good information: http://www.systemnetmail.com/