Skip to content

Exchange y VB.Net

December 4, 2012

Imports Microsoft.Office
Imports System.Net.Mail

   Dim fncEnviaMail As Boolean
        Dim MissatgeMail As New MailMessage()

        Try
            With MissatgeMail
                .To.Clear()
                .From = New MailAddress(“remitente@correo.com”)
                .To.Add(New MailAddress(“destino@correo.com”))
                             .Subject = “Informe automàtic de moviment de regularització d’estoc “
                .Body = “Article:       ” & Label2.Text & ”  –  ” & Label3.Text & vbCr & “Partida:       ” & Label7.Text & vbCr & “Quantitat:     ” & Label9.Text & vbCr & _
        “Tipus Mov.:    ” & tipMov & vbCr & “Usuari:        ” & usuari & vbCr
                .Priority = MailPriority.Normal
            End With

            With New SmtpClient
                .Host = “Dirección IP”
                .Send(MissatgeMail)
            End With

                    fncEnviaMail = True

        Catch ex As Exception
            MsgBox(ex.Message, MsgBoxStyle.Critical + MsgBoxStyle.OkOnly, “Error Enviant Mail”)
            fncEnviaMail = False
            Exit Sub
        End Try

    End Sub

La dirección del remitente no hace falta que sea real, puede ser inventada.

From → VB.NET y Office

Leave a Comment

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: