Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Visual Basic > VB 6 Visual Basic 6 > Beginning VB 6
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Beginning VB 6 For coders who are new to Visual Basic, working in VB version 6 (not .NET).
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Beginning 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 July 7th, 2010, 10:32 AM
Registered User
 
Join Date: Jul 2010
Location: Bangalore, Karnataka, India
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Send an email using MAPI sessions through VB 6.0

Hi All,
  1. I am trying to send an email using MAPI controls from my VB Application. But while sending email I will get an pop message from Microsoft outlook which says

    “A Program is trying to access e-mail address information
    stored in Outlook. If this is unexpected, click Deny and
    verify your anti virus software is up-to-date.


    For more information about e-mail safety and how you
    might be able to avoid getting this warning, click Help.”


    With a check box “Allow access for” and a combo box that shows the list of minutes from 1, 2, 5 & 10 minutes.

    With 3 buttons saying Allow, Deny & Cancel.
  2. After clicking on the allow button I will get another pop up message from Microsoft outlook which says

    “A Program is trying to access e-mail address information
    stored in Outlook. If this is unexpected, click Deny and
    verify your anti virus software is up-to-date.

    For more information about e-mail safety and how you

    might be able to avoid getting this warning, click Help.”


    With 3 buttons saying Allow, Deny & Cancel.
For each and every email that I send, I need to click on Allow button twice.

Please help me on how to disable this pop up message.

Below is the piece of code which I used to send email using MAPI Controls.

With frmMain
If .objMAPISess.SessionID = 0 Then
.objMAPISess.LogonUI = True
.objMAPISess.SignOn
End If

.objMAPIMess.SessionID = .objMAPISess.SessionID
.objMAPIMess.Compose
.objMAPIMess.AddressResolveUI = True

.objMAPIMess.AttachmentPathName = App.Path & "\Mail\" & p_strFileName & ".pdf"

If (Trim(p_strEmailID) <> "") Then
.objMAPIMess.AddressResolveUI = False
.objMAPIMess.RecipIndex = 0
.objMAPIMess.RecipType = 1
.objMAPIMess.RecipAddress = p_strEmailID
.objMAPIMess.ResolveName

.objMAPIMess.RecipIndex = 1
.objMAPIMess.RecipType = 3
.objMAPIMess.RecipAddress = strFacilityEMail
.objMAPIMess.ResolveName

.objMAPIMess.MsgSubject = p_strSubject
.objMAPIMess.MsgNoteText = p_strMessage
.objMAPIMess.send showDialog:=False 'True
End If
End With

Thanks & Regards
Lakshmi Kumar
Reply With Quote
  #2 (permalink)  
Old July 9th, 2010, 01:45 AM
Authorized User
 
Join Date: Mar 2009
Posts: 49
Thanks: 0
Thanked 8 Times in 8 Posts
Default

EnunWindows, EnumChildWindows, and SendMessage are a few of the API's you will need to use to solve this...



Good Luck
Reply With Quote
  #3 (permalink)  
Old July 9th, 2010, 01:59 AM
Registered User
 
Join Date: Jul 2010
Location: Bangalore, Karnataka, India
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thank you for your help. But I dont know how to use these API's. Please give me some sample coding if you have.
Reply With Quote
  #4 (permalink)  
Old July 9th, 2010, 09:12 AM
Authorized User
 
Join Date: Mar 2009
Posts: 49
Thanks: 0
Thanked 8 Times in 8 Posts
Default

Use your friends (yahoo, google, ask, answers, bing) and search for vb6 api name... like vb6 findwindow to find a ton of examples, if not more than a ton....



Good Luck
Reply With Quote
  #5 (permalink)  
Old December 24th, 2012, 12:34 AM
Registered User
Points: 25, Level: 1
Points: 25, Level: 1 Points: 25, Level: 1 Points: 25, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Nov 2010
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default I use vb 6 with Windows Live to send email

'you need to have MAPI as a component on your form.
If MAPISession1.NewSession Then
' check if session is already opened
Else
With MAPISession1 'MAPISession
' Set DownLoadMail to False to prevent immediate download.
.DownLoadMail = False
' Use the underlying email system's logon UI.
' .UserName = "john02813@hotmail.com"
' .Password = "hotrunner12"
' .LogonUI = True
.SignOn
.NewSession = True
MAPIMessages1.SessionID = .SessionID
End With

With MAPIMessages1 'MAPIMessage

' .SessionID = MAPISession1.SessionID
' .Fetch
' For i = 0 To .MsgCount - 1
' .MsgIndex = i
' lst.AddItem .MsgSubject
' lst.ItemData(lst.NewIndex) = i
' Next
.Compose
.RecipDisplayName = "John Alexander"
.RecipAddress = "john02813@hotmail.com"
.AddressResolveUI = True

.MsgSubject = "Just another VB test"
.MsgNoteText = "I am still trying to send you email from VB"
.Send False
.SessionID = MAPISession1.SessionID

End With
MAPISession1.NewSession = False ' Flag for new session.
MAPISession1.SignOff

End If
Me.MousePointer = vbDefault
Reply With Quote
  #6 (permalink)  
Old December 11th, 2013, 07:40 AM
Registered User
Points: 3, Level: 1
Points: 3, Level: 1 Points: 3, Level: 1 Points: 3, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Dec 2013
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Sending Mail Using MAPI

When i try to send a mail using the below mentioned code an exception occurs on sign on that "Error in loading MAPI DLL". Now when i try add mapi32.dll as a reference by browsing it form c:\Windows\System32\mapi32.dll it cannot be added as a reference showing that it is not a valid COM component. So what should i do to SignOn in the code mentioned below.

Dim mapisession1 As New MSMAPI.MAPISession
Dim MAPIMessages1 As New MSMAPI.MAPIMessages
mapisession1.LogonUI = True
'mapisession1.UserName = "abc@gmail.com"
'mapisession1.Password = "**********"
mapisession1.SignOn()
With MAPIMessages1
.SessionID = mapisession1.SessionID
.Compose()
.MsgSubject = "test"
.RecipIndex = 0
.RecipAddress = "xyz@yahoo.co.in"
.ResolveName()
.MsgNoteText = "Here You go"
'.AttachmentIndex = 0
'.AttachmentPosition = 0
'.AttachmentPathName = strFilePath

.Send()
End With
mapisession1.SignOff()
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
ASP VB.Net send email Greavr ASP.NET 2.0 Basics 3 August 26th, 2008 07:59 PM
read/send email using WEBDEV and vb.net prashanthudupa.k Excel VBA 0 September 21st, 2006 06:39 AM
Using Mapi to send emails in VBA - Help? Magic_Hat Excel VBA 1 May 4th, 2004 07:59 AM
Using Mapi to send emails in VBA - Help pls Magic_Hat Access VBA 0 April 21st, 2004 07:29 AM



All times are GMT -4. The time now is 10:40 AM.


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