473,378 Members | 1,457 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

Send Email with Attachment Using vb

Any1 can tell me how to go about sending email with attachment in vb programming code. I know SMTP is one option, but I can't seem to get it working. Any other suggestion??

Thanks in advance
Oct 3 '08 #1
4 2143
jg007
283 100+
smtp as you stated is one option but depending on who your end users are you can also use the office inerop components

I will have a look later and try to find / work out some working email code for the smtp , I believe that you have to send the email as html and convert the file to a mime encodement somehow.
Oct 3 '08 #2
smtp as you stated is one option but depending on who your end users are you can also use the office inerop components

I will have a look later and try to find / work out some working email code for the smtp , I believe that you have to send the email as html and convert the file to a mime encodement somehow.
here is my code( i got 3 sets of code) , but all 3 is not working, and i don't know where went wrong, Please Help! Thanks in advance

'''''''''''''''''''''''''''''''''''''''''''''''''' ''''''''''''''''''''''''''''''''''''''''''''
'Web.Mail.SmtpMail.SmtpServer = "user1"
'Dim msg As New Web.Mail.MailMessage

'msg.From = "weijie@admin"
'msg.To = "weijie1412@hotmail.com"
'msg.Subject = "testing"
'msg.Body = "hello first email"
'msg.BodyFormat = Web.Mail.MailFormat.Text

'Web.Mail.SmtpMail.Send(msg)

'MsgBox("Yea")
'''''''''''''''''''''''''''''''''''''''''''''''''' '''''''''''''''''''''''''''''''''''''''''''''
'Dim msg As System.Web.Mail.MailMessage
'Dim smtp As System.Web.Mail.SmtpMail
'Dim att As System.Web.Mail.MailAttachment

'msg.To = "weijie1412@hotmail.com"
'msg.From = "weijie1412@gmail.com"
'msg.BodyFormat = MailFormat.Text
'msg.Body = " testing, Please work pls "
'msg.Cc = " Cc: Testing, Please Work "
'msg.Subject = "Testing purpose"


'smtp.Send(msg)

'''''''''''''''''''''''''''''''''''''''''''''''''' ''''''''''''''''''''''''''''''''''''''''''''''''
'Dim message As System.Net.Mail.MailMessage
'Dim smtp As New System.Net.Mail.SmtpClient("smtp.gmail.com", 587)

''Dim attach As System.Net.Mail.Attachment
'Dim sFrom As String, sTo As String, sSsub As String, sMsg As String
''Dim sFile As String

'sFrom = "user1.edel@gmail.com"
'sTo = "weijie1412@hotmail.com"
''sFile = "D:\\j\\j5\\h\\tgk\\net\\eml1\\e2\\emlcmds.txt "
'sSsub = "t w"
'sMsg = "a"

'message = New System.Net.Mail.MailMessage(sFrom, sTo, sSsub, sMsg)

''If My.Computer.FileSystem.FileExists(sFile) Then
'' attach = New System.Net.Mail.Attachment(sFile)
'' message.Attachments.Add(attach)
''End If

'smtp.EnableSsl = True
'smtp.Credentials = New System.Net.NetworkCredential("user1.edel@gmail.com ", "pwd")

'Try
' smtp.Send(message)
' Console.WriteLine("Sent")
'Catch exc As Net.Mail.SmtpException
' Console.WriteLine(exc.StatusCode.ToString)
'End Try

'tbxEmail.Text = ""

'''''''''''''''''''''''''''''''''''''''''''''''''' ''''''''''''''''''''''''''''''''''''''''''
Oct 7 '08 #3
jg007
283 100+
if I have a chance I will look through the code and try to see what is wrong but meanwhile try looking at this tutorial -

http://www.codeproject.com/KB/vb/SendMail.aspx
Oct 7 '08 #4
Hi

THis is the easy way to do that. Put this code insite a Buttom Click event

[code]

Dim mySmtp As New System.Net.Mail.SmtpClient
mySmtp.Host = "192.168.2.1" 'or your correct smtp server name i.e. "smtp.terra.com"
Try
mySmtp.Send("rpicilli@terra.com.br", "toyou@docstibrasil.com.br", "Teste com .NET", "Hi there")
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try

/[code]


I hope this help
Oct 8 '08 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

8
by: John Brock | last post by:
I am currently using a VB.NET program to send out e-mails with plain text bodies (plus one attachment). The emails are being received as Rich Text messages (probably just my personal Outlook...
4
by: Max | last post by:
hi I am using System.Web.Mail.MailMessage with System.Web.Mail.SmtpMail to send mail. now the my question is, Is it compulsory to add fields smtpauthenticate, sendusername and sendpassword...
3
by: sentiboy | last post by:
I am using the following code for sending email through mapi in VS 2005 environment: Public objSession As New MSMAPI.MAPISession Public objMessage As New MSMAPI.MAPIMessages ...
3
by: =?Utf-8?B?SHVnaA==?= | last post by:
Hi There, I use follow code to send email inside VB.NET 2005. It does not work well. Error message of "Failure sending email" would occue. However, email was sent out sometimes. I am confused...
1
by: shil | last post by:
Hi, I'm using FW 2.0 to send an email with an attachment using System.Net.Mail class. If I try to attach a file from my file system, I could successfully send the eamil. But I need to generate a...
2
by: =?Utf-8?B?TWlrZQ==?= | last post by:
Hi Guys, I'm using this code to send an email with attachment but it's not working !! So, what I'm missing!!? knowing that both From & To email addresses are correct? MailMessage msgMail =...
1
by: zivon | last post by:
now for the bigger problam :) I know you pepole hate using OE for sending emails, but its user friendly and its needed in this case... I found on this forum, a code that sends email using OE...
1
by: Chitu03 | last post by:
Hi I am already send a mail using Php with some attachement into it. My Problem is the attachement file is in my Database(mysql). I don't know how can i get from database and then add to my mail....
1
by: sxwend | last post by:
I am trying to use the following post results (http://www.thescripts.com/forum/thread189759.html) and add another requirement. I need to send the results to just the email addresses that the query...
1
by: deepaks85 | last post by:
Dear All, I want to send some data through a form with Multiple attachment in an HTML Format. I have tried it but it is not working for me. I am able to send data without attachment but with the...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.