Solved

how to send an email from  your default e-mail

Posted on 2004-09-28
10
355 Views
Last Modified: 2010-04-23
hi,#

can any one give me an example on how to use mapi in vb.net or how can i send an email using the default email in vb.net


thanks

0
Comment
Question by:gajender_99
10 Comments
 
LVL 25

Expert Comment

by:RonaldBiemans
ID: 12168222
This is the easiest way
dim s as string = "bla.bla@bla.com"
 Process.Start("mailto:" & s)
0
 
LVL 8

Author Comment

by:gajender_99
ID: 12168258
hi,

can your give me more information how to attach a file, subject and body also

and if possible auto send

i would give extra points for this
0
 
LVL 25

Expert Comment

by:RonaldBiemans
ID: 12168360
Ah, then you have to go a completly different way. Here is one

Imports System.Web.Mail

    Friend Function SendEmail(ByVal strAppSending As String, ByVal strErrMsg As String) As String
        Dim strAnswer As String = "False"
        Try
            Dim Mail As SmtpMail
            Dim MailMsg As New MailMessage()

            With MailMsg
                '   .To = "cbsse_appmsg@Mail.com"
                .To = "<programmers email address>"
                .Cc = "<programmers email address>"
                .From = strAppSending + "@<Company Name>.com"
                .BodyFormat = MailFormat.Html
                .Priority = MailPriority.High
                .Subject = "App Error"
                .Body = strErrMsg
            End With
            SmtpMail.SmtpServer = "<your SMTP servers IP address>"
            SmtpMail.Send(MailMsg)

            Mail = Nothing
            MailMsg = Nothing
            strAnswer = "True"
        Catch
            strAnswer = Err.Description + ". From Global Function { SendEmail}"
        End Try
        SendEmail = strAnswer
    End Function
0
 
LVL 8

Author Comment

by:gajender_99
ID: 12168412
hi
 i like the first one but how can you attach a file to it
0
 
LVL 69

Expert Comment

by:Éric Moreau
ID: 12168542
The mailto protocol almost never allow attachments.
0
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 25

Accepted Solution

by:
RonaldBiemans earned 125 total points
ID: 12168549
You mean the mailto ?

Process.Start("mailto:bla.bla@bla.com?subject=test&body=test&attachment='c:\test.gif'")

but this won't auto send, I don't thing you can do that with mailto:
0
 
LVL 25

Expert Comment

by:RonaldBiemans
ID: 12168578
Remember aswell, that the attachment property doesn't work on all email clients. In the second example I gave, it will. Plus you can use autosend.
0
 
LVL 25

Expert Comment

by:RonaldBiemans
ID: 12168590
Ah, sorry emoreau, I didn't see your comment
0
 
LVL 28

Assisted Solution

by:iboutchkine
iboutchkine earned 125 total points
ID: 12168707
THis is an example how to use MAPI controls

'add 2 controls
Microsoft MAPIMessages (call it MAPIMessages1)
Microsoft MAPISession (call it MAPILogOn)
(AxInterop.MSMAPI.dll,  Interop.MSMAPI.dll)


Public Class Form1
    Inherits System.Windows.Forms.Form

#Region " Windows Form Designer generated code "
 
   Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim msg As String

        msg = "This is a test email from Iouri."
        With Me
            .MAPILogOn.SignOn() ' use current user
            Do While .MAPILogOn.SessionID = 0
                System.Windows.Forms.Application.DoEvents() ' need to wait until the new session is created
            Loop
            Call SendToEmail("someone@somewhere.com", msg)
            .MAPILogOn.SignOff()
        End With
        MsgBox("e-mail is sent")

    End Sub

    Private Sub SendToEmail(ByVal Email As String, ByVal msg As String)
        With MAPIMessages1
            'create a new message and address it
            .SessionID = MAPILogOn.SessionID
            .Compose()
            .RecipDisplayName = Email
            .AddressResolveUI = True
            .RecipAddress = "smtp:" & Email
            .MsgSubject = "VB GENERATED E-MAIL"
            .MsgNoteText =msg
            .Send(False)
        End With
    End Sub

End Class
0
 
LVL 8

Author Comment

by:gajender_99
ID: 12179717
as i havent got a proper answer i would split the points

0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Performance enhancement 39 25
Need help with a query. 10 43
Asp/Net Validation date Issue 9 37
Saveas need to save a copy 16 0
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now