Wrox Programmer Forums

Need to download code?

View our list of code downloads.

| FAQ | Members List | Search | Today's Posts | Mark Forums Read
Pro VB 6 For advanced Visual Basic coders working in version 6 (not .NET). Beginning-level questions will be redirected to other forums, including Beginning VB 6.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Pro VB 6 section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old June 11th, 2003, 09:30 PM
Authorized User
 
Join Date: Jun 2003
Location: Sydney, NSW, Australia.
Posts: 20
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to alantodd
Default MAPI

Hi Everyone,

I am building an application in VB 6.0 that needs to be able to send e'mails. I have included the MAPI controls MAPIMessage & MAPISession and all is working well on workstations that are using MS Outlook Express as their e'mail client. However, on the workstations that are using MS Outlook, everytime you send your message, the system generates an error message that reads 'Unspecified Failure has occured'

Not much help unfortunately.

Has anyone else seen this?

Any suggestions?

Thanks,

Alan Todd

P.S. Here is the code:

MAPISess.SignOn
MAPIMess.SessionID = MAPISess.SessionID
MAPIMess.Compose
MAPIMess.RecipAddress = To.Text
MAPIMess.AddressResolveUI = True
MAPIMess.MsgSubject = Subject.Text
MAPIMess.MsgNoteText = Body.Text
MAPIMess.Send
MAPISess.SignOff
Reply With Quote
  #2 (permalink)  
Old June 12th, 2003, 09:02 AM
Authorized User
 
Join Date: Jun 2003
Location: Goodlands, n/a, Mauritius.
Posts: 15
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to psychadelic
Default

Hello Alan, Hi everybody,

I am using this piece of code to send mail in my VB app and I've no problem with Ms Outlook. I have cut some of it but I think you could make good use of the following. Hope it works out for you. And if someone wants to add something or comment please do.

regards,

psychadelic

Code:
Private Sub miFMailDirect_Click()

    On Error GoTo err_miFMailDirect_Click

    Dim sFileName As String
    Dim sRecipient As String
    Dim sSubject As String
    Dim sBody As String

    Me.MousePointer = vbHourglass
'   set filename if you want to do attachment, body, recipient etc
    sFileName = ""
    sRecipient = ""
    sSubject = ""
    sBody = ""
    If mapSess.NewSession Then
'       check if session is already opened
    Else
        With mapSess        'MAPISession
'           Set DownLoadMail to False to prevent immediate download.
            .DownLoadMail = False
'           Use the underlying email system's logon UI.
            .LogonUI = True
            .SignOn
            .NewSession = True
            mapMess.SessionID = .SessionID
        End With
        With mapMess        'MAPIMessage
            .MsgIndex = -1
            .Compose
            .RecipIndex = 0
            .RecipType = 1
            .RecipAddress = sRecipient
            .MsgSubject = sSubject
            .MsgNoteText = sBody
'           attachment
            If sFileName <> "" Then
                .AttachmentIndex = 0
                .AttachmentPosition = 0
                .object.AttachmentName = sFileName
                .AttachmentPathName = (sFileName)
            End If
            .AddressResolveUI = False
            .ResolveName
            DoEvents
            .Send False
            MsgBox "Mail has been sent successfully.", vbInformation, App.Title
        End With
        mapSess.SignOff
        mapSess.NewSession = False ' Flag for new session.
    End If
    Me.MousePointer = vbDefault
    Exit Sub

err_miFMailDirect_Click:
    Select Case Err.Number
        Case 32002, 32001
            MsgBox "Mail cannot be sent! Error unknown.", vbExclamation, App.Title
            Me.MousePointer = vbDefault
            Exit Sub
        Case Else
            MsgBox "Error# : " & Err.Number & Chr$(10) & _
                Err.Description, vbExclamation, App.Title & " : miFMailDirect_Click"
            Me.MousePointer = vbDefault
            Exit Sub
    End Select

End Sub
Reply With Quote
  #3 (permalink)  
Old June 12th, 2003, 09:11 AM
Registered User
 
Join Date: Jun 2003
Location: Zürich, , Switzerland.
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to Kilian
Default

Hi a other easy way is like this :
But you have to link the right dll's !!

    Dim outApp As Outlook.Application
    Set outApp = New Outlook.Application
    Dim outMAPI As Outlook.NameSpace
    Dim outFolder As Outlook.MAPIFolder
    Dim outMail As Outlook.MailItem
    Set outApp = New Outlook.Application
    Set outMAPI = outApp.GetNamespace("MAPI")
    Set outFolder = outMAPI.GetDefaultFolder(olFolderOutbox)
    Set outMail = outFolder.Items.Add

    outMail.To = "user@domain.ch"
    outMail.Subject = "Txt-File"
    outMail.Body = "Hallo"
    outMail.Send

cheers Kilian
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
MAPI question - need help rlorenco Visual C++ 2005 0 March 7th, 2008 06:24 AM
MAPI BobR VB Components 0 February 7th, 2005 07:47 PM
MAPI in Excel raceman Excel VBA 1 January 14th, 2005 02:41 AM
MAPI help kane C++ Programming 2 October 13th, 2004 12:41 AM
MAPI and Domino5 leverell Pro VB 6 1 August 14th, 2003 08:36 PM



All times are GMT -4. The time now is 08:03 AM.


Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.