Send Email and Attachment using VB.Net

I am looking for an example of auto-email
to populate:
   TO,CC,BODY.
In the body, a standard message is structured. Also it would add the attachment which is in the
C:\Sent\.. folder
My email system is  Groupwise/Novell...
Do I need to use somekind of Group wise Type Library? Thanks
zachvaldezAsked:
Who is Participating?
 
twolConnect With a Mentor Commented:
from
http://www.freevbcode.com/ShowCode.asp?ID=5486

Imports System.Web.Mail
Imports System.IO

   'TWO FUNCTIONS
    'SAME EXCEPT FIRST TAKES A STRING FOR ATTACHMENT
    'SECOND TAKES AN ARRAY LIST SO YOU CAN SEND MULTIPLE 
         'ATTACHMENTS
    'FROM: Email address FRom
    'TO: EMAIL address To
    'Subject: Subject; Body: MessageText
    'Optional CC, BCC: CC and bcc recipients
    'SMTPSERVER: Optional, if not specified 
   'local machine is used
    'AttachmentFile (first function: Optional, file name)
    'AttachmentFiles (second function: Optional, list of     
        'attachments in form of an array list)

    Public Sub SendMailOneAttachment(ByVal From As String, _
      ByVal sendTo As String, ByVal Subject As String, _
      ByVal Body As String, _
      Optional ByVal AttachmentFile As String = "", _
      Optional ByVal CC As String = "", _
      Optional ByVal BCC As String = "", _
      Optional ByVal SMTPServer As String = "")

        Dim myMessage As MailMessage

        Try
            myMessage = New MailMessage()
            With myMessage
                .To = sendTo
                .From = From
                .Subject = Subject
                .Body = Body
                .BodyFormat = MailFormat.Text
                'CAN USER MAILFORMAT.HTML if you prefer

                If CC <> "" Then .Cc = CC
                If BCC <> "" Then .Bcc = ""

                If FileExists(AttachmentFile) Then _
                 .Attachments.Add(AttachmentFile)

            End With

            If SMTPServer <> "" Then _
               SmtpMail.SmtpServer = SMTPServer
            SmtpMail.Send(myMessage)

        Catch myexp As Exception
            Throw myexp
        End Try

    End Sub

Public Sub SendMailMultipleAttachments(ByVal From As String,_
    ByVal sendTo As String, ByVal Subject As String, _
    ByVal Body As String, _
    Optional ByVal AttachmentFiles As ArrayList = Nothing, _
    Optional ByVal CC As String = "", _
    Optional ByVal BCC As String = "", _
    Optional ByVal SMTPServer As String = "")

        Dim myMessage As MailMessage
        Dim i, iCnt As Integer

        Try
            myMessage = New MailMessage()
            With myMessage
                .To = sendTo
                .From = From
                .Subject = Subject
                .Body = Body
                .BodyFormat = MailFormat.Text
                'CAN USER MAILFORMAT.HTML if you prefer

                If CC <> "" Then .Cc = CC
                If BCC <> "" Then .Bcc = ""

                If Not AttachmentFiles Is Nothing Then
                    iCnt = AttachmentFiles.Count - 1
                    For i = 0 To iCnt
                        If FileExists(AttachmentFiles(i)) Then _
                          .Attachments.Add(AttachmentFiles(i))
                    Next

                End If

            End With

            If SMTPServer <> "" Then _
              SmtpMail.SmtpServer = SMTPServer
            SmtpMail.Send(myMessage)


        Catch myexp As Exception
            Throw myexp
        End Try
    End Sub

    Private Function FileExists(ByVal FileFullPath As String) _
     As Boolean
        If Trim(FileFullPath) = "" Then Return False

        Dim f As New IO.FileInfo(FileFullPath)
        Return f.Exists

    End Function

Open in new window

0
 
Alfred A.Commented:
0
 
zachvaldezAuthor Commented:
Does this code need a reference to Groupwise/novell type library just like when doing a Outlook message?
0
Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

 
twolCommented:
This will give you specific FAQs:

http://www.systemwebmail.com/allfaq.aspx
0
 
zachvaldezAuthor Commented:
Thanks for the article. It significantly talks about CDO which is Outlook based.
Im using groupwise/novell.
0
 
Henry RohlfsCommented:
Start by going to Novell's developer site for GroupWise: http://www.novell.com/developer/develop_to_groupwise.html. There you can find the SDK for GroupWise and code examples in a few different languages.

Here's a support article on the GroupWise API with VB examples: http://support.novell.com/techcenter/articles/ana20000813.html

And here's a recent Novell forum post on the subject: http://forums.novell.com/novell-product-support-forums/groupwise/version-independent-forums/gw-messenger/389682-visual-basic-sample-groupwise-messenger-api.html

Don't forget that the GroupWise client must be installed for your API code to work.
0
 
zachvaldezAuthor Commented:
thanks,
>>>>Don't forget that the GroupWise client must be installed for your API code to work
Since I am using groupwise for email,does that mean the clent is already installed in my PC?
Just to clarify...
0
 
Henry RohlfsCommented:
If your email client has the selection "About GroupWise" under the "Help" menu, then yes the GroupWise client is installed. If you use Outlook to access your GroupWise emails, then you may need to install the GroupWise client on your pc.

Which version of GroupWise do you use?
0
 
zachvaldezAuthor Commented:
version 8
0
 
Henry RohlfsCommented:
Perfect. There isn't much difference in the API between version 8 and prior versions, but the forum post I gave you shows code used in a v8 environment.
0
 
zachvaldezAuthor Commented:
Th examples look like classic VB and not VB.NET. BUt I could be wrong
0
 
Henry RohlfsCommented:
Ok, I searched Novell's Cool Solutions and found this article that is VB.NET specific.

http://www.novell.com/coolsolutions/tools/14096.html
0
 
zachvaldezAuthor Commented:
How does Groupwise API work with VB.NET?
How is it structured in code?
What namespace is declared in vb code?
0
 
zachvaldezAuthor Commented:
thanks for getting back to this question. Im still at a lost to how to mix gw and vb.net
0
 
zachvaldezAuthor Commented:
this link brings in an empty page
http://www.novell.com/coolsolutions/trench/9694.html

0
 
CodeCruiserCommented:
The link contains a link to the download page for sample project


Download it here: http://www.ipdg3.com/sourcecoderesults.php?option=sourcecode&id=000464 
0
 
zachvaldezAuthor Commented:
I get page not found and instruction to upload web site or something
0
 
zachvaldezAuthor Commented:
Try
            myMessage = New MailMessage()
            With myMessage
                .To = sendTo>>> its telling its readonly
0
 
CodeCruiserConnect With a Mentor Commented:
.To is a collection.

Use

.To.Add(sendTo)
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.