473,569 Members | 2,422 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Send Email with Attachment Using vb

2 New Member
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 2161
jg007
283 Contributor
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
PleaseHelpMe
2 New Member
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.SmtpM ail.SmtpServer = "user1"
'Dim msg As New Web.Mail.MailMe ssage

'msg.From = "weijie@adm in"
'msg.To = "weijie1412@hot mail.com"
'msg.Subject = "testing"
'msg.Body = "hello first email"
'msg.BodyFormat = Web.Mail.MailFo rmat.Text

'Web.Mail.SmtpM ail.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@hot mail.com"
'msg.From = "weijie1412@gma il.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("sm tp.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@gma il.com"
'sTo = "weijie1412@hot mail.com"
''sFile = "D:\\j\\j5\\h\\ tgk\\net\\eml1\ \e2\\emlcmds.tx t"
'sSsub = "t w"
'sMsg = "a"

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

''If My.Computer.Fil eSystem.FileExi sts(sFile) Then
'' attach = New System.Net.Mail .Attachment(sFi le)
'' message.Attachm ents.Add(attach )
''End If

'smtp.EnableSsl = True
'smtp.Credentia ls = New System.Net.Netw orkCredential(" user1.edel@gmai l.com", "pwd")

'Try
' smtp.Send(messa ge)
' Console.WriteLi ne("Sent")
'Catch exc As Net.Mail.SmtpEx ception
' Console.WriteLi ne(exc.StatusCo de.ToString)
'End Try

'tbxEmail.Text = ""

''''''''''''''' ''''''''''''''' ''''''''''''''' ''''''''''''''' ''''''''''''''' ''''''''''''''' ''
Oct 7 '08 #3
jg007
283 Contributor
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
rpicilli
77 New Member
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("rp icilli@terra.co m.br", "toyou@docstibr asil.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
17044
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 default, because I didn't do this in the program), but there is no actual formatting (italics, color, etc.) in the message body, which is passed to from...
4
2355
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 fields to MailMessage Object????. mm.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", "1")
3
4678
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 objSession.DownLoadMail = False objSession.UserName = "MyUsername" objSession.Password = "MyPassword" objSession.SignOn()
3
9737
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 and please help. Thanks in advance. Hugh
1
9266
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 report on the fly and send an email with that report as an attachment. Here is the code I have. ...
2
1541
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 = new MailMessage(); msgMail.To = "badisrochdi@yahoo.com"; msgMail.From = "badisr@bigpond.com"; msgMail.Subject = "Attachment Test";
1
2717
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 with attachments. it works, but with two problams... first, its directly sends the email, without opening the OE "editing mode" of the email, like...
1
2410
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. <?php function send_mail($emailaddress, $fromaddress, $emailsubject, $body, $ccaddress, $attachments=false) { $eol="\r\n"; ...
1
6545
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 specifies for each record... Essentially this is a make shift Ordering Tool and I want to be able to notify the receiver of the order and its specifics....
1
3199
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 code for attachment, I am not able to send anything. I get blank email. Can you please help me on this? Here is the html form:
0
7618
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7926
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8132
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7678
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7982
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6286
agi2029
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5514
isladogs
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3656
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
2116
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.