473,806 Members | 2,330 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Sending web email

I am trying to send web email in vs2005, but haven't succeeded so far.
I found an example in C# to make a Console application.
The top of the code is
using System;
using System.Web.Mail ;
I have added a reference System.Web.
When I run the code I get warnings saying that System.Web.Mail Message is
'obsolete'.
Alternative is System.Net.Mail .MailMessage
When I change the System.Web.Mail to System.Net.Mail , I can't find any
reference for System.Net.Mail
Does anybody have a good example to follow just to send a plain web email
whith From, To, Message, Body and Attachment.
Preferrably in Vb.

regards
reidarT
Mar 14 '06 #1
4 1427
i use this in all my projects
Imports System.Net.Mail

Private Function fsmtpClient() As SmtpClient

fsmtpClient = New
SmtpClient(Conf igurationManage r.AppSettings(" smtpHost").ToSt ring,
Integer.Parse(C onfigurationMan ager.AppSetting s("smtpPort") ))

fsmtpClient.Use DefaultCredenti als = True

End Function

Public Shared Sub adminErrorMail( ByVal msg As String, Optional ByVal
Notification As Boolean = False)

Dim mMsg As New MailMessage

If Notification Then

mMsg.Subject = "H-base.com Notification : " & Now.ToString

Else

mMsg.Subject = "H-base.com Application error occured : " & Now.ToString

End If

mMsg.From = New MailAddress(Con figurationManag er.AppSettings( "errMailFro m"))

mMsg.Priority = MailPriority.Hi gh

mMsg.Body = msg

Dim errto() As String =
ConfigurationMa nager.AppSettin gs("errMailTo") .Split(CChar("; "))

For Each adress As String In errto

mMsg.To.Add(New MailAddress(adr ess))

Next

fsmtpClient.Sen d(mMsg)

End Sub

this works perfect :-)

regards

Michel posseth [MCP]

"Reidar" <re****@eivon.n o> wrote in message
news:OG******** *****@TK2MSFTNG P14.phx.gbl...
I am trying to send web email in vs2005, but haven't succeeded so far.
I found an example in C# to make a Console application.
The top of the code is
using System;
using System.Web.Mail ;
I have added a reference System.Web.

When I run the code I get warnings saying that System.Web.Mail Message is
'obsolete'.
Alternative is System.Net.Mail .MailMessage
When I change the System.Web.Mail to System.Net.Mail , I can't find any
reference for System.Net.Mail
Does anybody have a good example to follow just to send a plain web email
whith From, To, Message, Body and Attachment.
Preferrably in Vb.

regards
reidarT

Mar 14 '06 #2
Could you help me a bit more.
Are you placing this code in a webform with txtfields To, CC, Message,
Body...
or what?
reidar
"m.posseth" <mi*****@nohaus ystems.nl> skrev i melding
news:up******** ******@TK2MSFTN GP14.phx.gbl...
i use this in all my projects
Imports System.Net.Mail

Private Function fsmtpClient() As SmtpClient

fsmtpClient = New
SmtpClient(Conf igurationManage r.AppSettings(" smtpHost").ToSt ring,
Integer.Parse(C onfigurationMan ager.AppSetting s("smtpPort") ))

fsmtpClient.Use DefaultCredenti als = True

End Function

Public Shared Sub adminErrorMail( ByVal msg As String, Optional ByVal
Notification As Boolean = False)

Dim mMsg As New MailMessage

If Notification Then

mMsg.Subject = "H-base.com Notification : " & Now.ToString

Else

mMsg.Subject = "H-base.com Application error occured : " & Now.ToString

End If

mMsg.From = New
MailAddress(Con figurationManag er.AppSettings( "errMailFro m"))

mMsg.Priority = MailPriority.Hi gh

mMsg.Body = msg

Dim errto() As String =
ConfigurationMa nager.AppSettin gs("errMailTo") .Split(CChar("; "))

For Each adress As String In errto

mMsg.To.Add(New MailAddress(adr ess))

Next

fsmtpClient.Sen d(mMsg)

End Sub

this works perfect :-)

regards

Michel posseth [MCP]

"Reidar" <re****@eivon.n o> wrote in message
news:OG******** *****@TK2MSFTNG P14.phx.gbl...
I am trying to send web email in vs2005, but haven't succeeded so far.
I found an example in C# to make a Console application.
The top of the code is
using System;
using System.Web.Mail ;
I have added a reference System.Web.

When I run the code I get warnings saying that System.Web.Mail Message is
'obsolete'.
Alternative is System.Net.Mail .MailMessage
When I change the System.Web.Mail to System.Net.Mail , I can't find any
reference for System.Net.Mail
Does anybody have a good example to follow just to send a plain web email
whith From, To, Message, Body and Attachment.
Preferrably in Vb.

regards
reidarT


Mar 14 '06 #3
Well i have placed the code in a public class so all my pages can use it
( it was a actuall copy paste of functioning code in one of my projects )

here is a simplified version in one method

Public Shared Sub SendMail(ByVal msg As String, ByVal Mailto As String)

Dim mMsg As New MailMessage

mMsg.Subject = "Your Subject"

mMsg.From = New MailAddress("No *****@youradres s.com")

mMsg.Body = msg

mMsg.To.Add(New MailAddress(Mai lto))

Dim smtpclient As New SmtpClient("You rHost(NameOrIp) ", 25)

smtpclient.Send (mMsg)

End Sub


"Reidar" <re****@eivon.n o> wrote in message
news:Ov******** ******@tk2msftn gp13.phx.gbl...
Could you help me a bit more.
Are you placing this code in a webform with txtfields To, CC, Message,
Body...
or what?
reidar
"m.posseth" <mi*****@nohaus ystems.nl> skrev i melding
news:up******** ******@TK2MSFTN GP14.phx.gbl...
i use this in all my projects
Imports System.Net.Mail

Private Function fsmtpClient() As SmtpClient

fsmtpClient = New
SmtpClient(Conf igurationManage r.AppSettings(" smtpHost").ToSt ring,
Integer.Parse(C onfigurationMan ager.AppSetting s("smtpPort") ))

fsmtpClient.Use DefaultCredenti als = True

End Function

Public Shared Sub adminErrorMail( ByVal msg As String, Optional ByVal
Notification As Boolean = False)

Dim mMsg As New MailMessage

If Notification Then

mMsg.Subject = "H-base.com Notification : " & Now.ToString

Else

mMsg.Subject = "H-base.com Application error occured : " & Now.ToString

End If

mMsg.From = New
MailAddress(Con figurationManag er.AppSettings( "errMailFro m"))

mMsg.Priority = MailPriority.Hi gh

mMsg.Body = msg

Dim errto() As String =
ConfigurationMa nager.AppSettin gs("errMailTo") .Split(CChar("; "))

For Each adress As String In errto

mMsg.To.Add(New MailAddress(adr ess))

Next

fsmtpClient.Sen d(mMsg)

End Sub

this works perfect :-)

regards

Michel posseth [MCP]

"Reidar" <re****@eivon.n o> wrote in message
news:OG******** *****@TK2MSFTNG P14.phx.gbl...
I am trying to send web email in vs2005, but haven't succeeded so far.
I found an example in C# to make a Console application.
The top of the code is
using System;
using System.Web.Mail ;
I have added a reference System.Web.

When I run the code I get warnings saying that System.Web.Mail Message is
'obsolete'.
Alternative is System.Net.Mail .MailMessage
When I change the System.Web.Mail to System.Net.Mail , I can't find any
reference for System.Net.Mail
Does anybody have a good example to follow just to send a plain web
email whith From, To, Message, Body and Attachment.
Preferrably in Vb.

regards
reidarT



Mar 14 '06 #4
"Reidar" <re****@eivon.n o> schrieb:
I am trying to send web email in vs2005, but haven't succeeded so far.
I found an example in C# to make a Console application.
The top of the code is
using System;
using System.Web.Mail ;
I have added a reference System.Web.
When I run the code I get warnings saying that System.Web.Mail Message is
'obsolete'.
Alternative is System.Net.Mail .MailMessage
When I change the System.Web.Mail to System.Net.Mail , I can't find any
reference for System.Net.Mail


'System.Net.Mai l' is implemented in "system.dll ", not "System.Web.dll ".

Additional information:

<URL:http://msdn2.microsoft .com/en-us/library/system.net.mail .mailmessage(VS .80).aspx>

<URL:http://www.systemnetma il.net/>

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Mar 14 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
7055
by: Paul Lamonby | last post by:
Hi, I am sending a file from the server as an email attachment. The file is being attached no problem and sending the email, but I get an error when I try to open it saying it is corrupt. Obviuosly, the file is fine on the server, so the attachment code I am using must be corrupting it, but I dont know what it is: // send email with attachment function emailAttachment($to, $subject, $message, $name, $email,
0
522
by: praba kar | last post by:
Dear All, I have doubt regarding mail sending smtplib module. The below code is I used to send a mail. ########################################## import email.Message import email.Utils import mimetypes import os,string
3
6836
by: VB Programmer | last post by:
I have an ASPX page where I send out emails through my mail server mail.MyDomain.com. When I send emails to MyName@MyDomain.com it sends PERFECTLY. When I try sending an email to any other address (non-MyDomain.com address) I get the following error: The server rejected one or more recipient addresses. The server response was: 550 You must check your mail from this IP or SMTP Auth before sending to BSmith@Juno.com Here's the FULL...
3
3627
by: Ant | last post by:
Hi, I'm using the MailMessage & smtpMail classes in System.Web.Mail to send mail, however it's not sending any emails. I'm using it on a Windows 2003 server. The simplest way to use this is smtpMail.Send("from@here.com", to@there.com, "Message subject", "Message Body") I'm sending it to my own email address on a different server using a dummy
1
8188
by: Eric Sheu | last post by:
Greetings, I have been searching the web like mad for a solution to my SMTP problem. I am using Windows Server 2003 and ASP.NET 2.0 w/ C# to send out e-mails from a web site I have created to the members of my organization. I think my problem is incorrectly setting the settings on my server or an authentication problem. Here is the code I have written to send a test message: -----Code Begins: Sensitive Information Replaced by -----...
2
12176
by: =?Utf-8?B?QWRl?= | last post by:
HI All, I am encountering the following error when I try to send an email through a SMTP server. I believe the problem lies with the authentication part when the network crednetials are used, error is thrown at the .send point. Error is: The following error occured Sending an email: System.ApplicationException: An error occurred sending an email To helen@HerMail.com From ade@MyMail.com Cc Subject A test with Finlistener #1. The body...
9
3478
by: JoeP | last post by:
Hi All, How can I find the reason for such an error: Failure sending mail. Some Code... oMailMessage.IsBodyHtml = False oMailMessage.Body = cEmailBody Dim oSMTP As New SmtpClient oSMTP.Send(oMailMessage) (in this line I am getting the above err)
7
3345
by: bleachie | last post by:
Hey, I just need some help, my form seems to not send me all of the 'guestNames' and 'guestEmails' forms. i use this function to add more guestnames and guestemail fields based on the number of guests added. form.php function createGuestNameAndEmailElements() {
10
5106
by: Markgoldin | last post by:
I am sending an XML data from not dontnet process to a .Net via socket listener. Here is a data sample: <VFPData> <serverdata> <coderun>updateFloor</coderun> <area>MD2</area> <zone>BOXING</zone> <status>Running</status> <job>1000139233</job>
31
12724
by: happyse27 | last post by:
Hi All, I am trying for weeks how to send email from windows pc, which from my gmail account to my hotmail account. Using net::smtp module sending email failed,Kindly assist. (for the item d it is working for normal email servers, but NOT with gmail server, I am very puzzled still!!) Codes(item c below) It keeps complaining and logs and codes are below. a) apache access logs --------------------------------- 127.0.0.1 - - "GET...
0
9719
marktang
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10366
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 captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10371
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 most users, this new feature is actually very convenient. If you want to control the update process,...
0
10110
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 choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6877
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5546
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 the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5678
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4329
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
2
3850
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.