Send an email in my application - again~

pisceswzh

Well-known member
Joined
Mar 19, 2007
Messages
96
Programming Experience
1-3
Dear all,

I read a lot of article on how to send an email thru VB.NET windows program, but most of which are using third party program like Outlook, or using another SMTP server.

Currently, I am using Outlook to send email, but the security warning is really annoying. I tried Redemption to skip the warning, but this module seems not working very well.

I am just wondering, whether it is possible for me to code my own SMTP service? I mean, I want everything to be done in my program, not to use any third party program or use another SMTP server. An email is just sent by my program.

I just hope anyone that can provide me with some resources, maybe some articles or links. Any kind of helps are really appreciated.

Thanks!
 
I am just wondering, whether it is possible for me to code my own SMTP service? I mean, I want everything to be done in my program, not to use any third party program or use another SMTP server. An email is just sent by my program.

coding an smtp server and all the supporting .net class libraries by yourself will be like reinventing the wheel.
 
coding an smtp server and all the supporting .net class libraries by yourself will be like reinventing the wheel.

Kinda...

But I have just found a better way and seems to work fine, with just so little coding:

Dim mail As New MailMessage()
mail.From = New MailAddress("Name@MyCompany.Com", "Display Name")
mail.To.Add("Name@YourCompany.Com")
mail.Subject = "This is an email"
mail.Body = "this is a sample body"
Dim smtp As New SmtpClient("athena.peiwei.com.cn")
smtp.Send(mail)

athena.peiwei.com.cn is our inhouse Exchange Server.
 
Arg81,

I'm using the Redemption Object library and am having 1 problem using it. The way I'm using it is that we are processing a file containing email information such as:

1. Sending Email Address
2. Receiving Email Address
3. Subject

VB.NET:
            Dim oItem As Object
            Dim strMsg As String = ""

            NameSpace1.logon()

            'Create an instance of Redemption.SafeMailItem 
            Dim safeMailItem As New Redemption.SafeMailItem

            'Create a new message
            oItem = Application.CreateItem(0)

            'Set Item property
            safeMailItem.Item = oItem

            [COLOR="Red"]safeMailItem.Sender.Address = strFrom[/COLOR]
            safeMailItem.Recipients.Add(strRecipient)
            safeMailItem.Recipients.ResolveAll()
            safeMailItem.Subject = strSubject & " " & Now.Date
            safeMailItem.Body = BodyText(strType)

            safeMailItem.Attachments.Add(strAttachment)
            safeMailItem.Send()

            safeMailItem = Nothing

My problem is the highlighted line of code. When it is executed, I get the "Object reference not set to in instance of an object" error. The Sender Property is a "ReadOnly" property, however, part of the functionality of the application is to provide numerous email addresses of the "Sender". There could be 100 different email addresses in the file that represent a different "Sender". How can I set this property?

Thanks,
 
Arg81,

I'm using the Redemption Object library and am having 1 problem using it. The way I'm using it is that we are processing a file containing email information such as:

1. Sending Email Address
2. Receiving Email Address
3. Subject

VB.NET:
            Dim oItem As Object
            Dim strMsg As String = ""

            NameSpace1.logon()

            'Create an instance of Redemption.SafeMailItem 
            Dim safeMailItem As New Redemption.SafeMailItem

            'Create a new message
            oItem = Application.CreateItem(0)

            'Set Item property
            safeMailItem.Item = oItem

            [COLOR="Red"]safeMailItem.Sender.Address = strFrom[/COLOR]
            safeMailItem.Recipients.Add(strRecipient)
            safeMailItem.Recipients.ResolveAll()
            safeMailItem.Subject = strSubject & " " & Now.Date
            safeMailItem.Body = BodyText(strType)

            safeMailItem.Attachments.Add(strAttachment)
            safeMailItem.Send()

            safeMailItem = Nothing

My problem is the highlighted line of code. When it is executed, I get the "Object reference not set to in instance of an object" error. The Sender Property is a "ReadOnly" property, however, part of the functionality of the application is to provide numerous email addresses of the "Sender". There could be 100 different email addresses in the file that represent a different "Sender". How can I set this property?

Thanks,

Please refer to the forum on OutlookCode.com for more detailed use of Redemption. I found it very good!
 
Back
Top