473,386 Members | 1,679 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

MAPI control problem

143 100+
Hi everyone..

i need ur help once more time.... i have a form called reminder..in tht form i have:
txtid, txtcaseid, txtreminder, cmbremindby(system or user), txtremindto, dtpreminddt, MAPISession1, MAPIMessages1, cmdReminder

in this case i have to set some fix reminder and fix date for every month tht automatically send by the system to some particular people...
i dont knw anything abt mapi control and have never used tht...
got some codes from the net bt didnt help me coz in my case the system has to send the reminder..
wld u plz help me with the code and tel me wht should i do?
thank u very much
Dec 30 '08 #1
15 8293
squrel
143 100+
is anyone thr to help me out with this????
Dec 30 '08 #2
squrel
143 100+
Hello everyone..
i need some help here if anyone has any idea, plz share wit me
thanks a lot
Jan 2 '09 #3
debasisdas
8,127 Expert 4TB
do you want to send those as e-mails ?
Jan 2 '09 #4
squrel
143 100+
yes i have to send them as a reminder(mail) to some particular people...
Jan 2 '09 #5
debasisdas
8,127 Expert 4TB
try this sample program. that might help you.

Expand|Select|Wrap|Line Numbers
  1. Private Sub Command2_Click()
  2. MAPISession1.SignOn
  3. MAPIMessages1.SessionID = MAPISession1.SessionID
  4. 'Compose new message
  5. MAPIMessages1.Compose
  6. 'Address message
  7. MAPIMessages1.RecipDisplayName = "diaplay name here"
  8. MAPIMessages1.RecipAddress = "recipient@server.com"
  9. ' Resolve recipient name
  10. MAPIMessages1.AddressResolveUI = True
  11. MAPIMessages1.ResolveName
  12. 'Create the message
  13. MAPIMessages1.MsgSubject = "Hi"
  14. MAPIMessages1.MsgNoteText = "Test mail"
  15. 'Add attachment
  16. MAPIMessages1.AttachmentPathName = "Path of the file to attach"
  17. 'Send ethe message
  18. MAPIMessages1.Send False
  19. MAPISession1.SignOff
  20. End Sub
  21.  
Jan 2 '09 #6
squrel
143 100+
i have tried this code but its not working.... i m getting error for tht mapito
is telling type mismatch... getting error in the bold line




Private Sub CmdReminder_Click()

Dim objSession As Object
Dim objMessage As Object
Dim objRecipient As Object
Dim mapito As Object
Dim MAPIMessages1 As MAPIMessages
Dim MAPISession1 As MAPISession

'Create the Session Object.
Set objSession = CreateObject("MAPI.SESSION")
'Logon using the session object.
'Specify a valid profile name if you want to.
'Avoid the logon dialog box.
objSession.Logon ProfileName:="Azi"
'Add a new message object to the OutBox.
Set objMessage = objSession.Outbox.Messages.Add
'Set the properties of the message object.
objMessage.Subject = "This is a test."
objMessage.Text = "This is the message text."
'Add a recipient object to the objMessage.Recipients collection.
Set objRecipient = objMessage.Recipients.Add
'Set the properties of the recipient object.
objRecipient.Name = "azita.mostaghni" '<---Replace this with a valid
'display name or e-mail alias
'Type can be ActMsgTo, mapiTo, or CdoTo for different CDO versions;
'they all have a constant value of 1.
objRecipient.Type = mapito
objRecipient.Resolve
'Send the message.
objMessage.Send showDialog:=False
MsgBox "Message sent successfully!"
'Logoff using the session object.
objSession.Logoff

End Sub
Jan 2 '09 #7
debasisdas
8,127 Expert 4TB
TRY THE CODE IN POST #6

that will work for you.
Jan 2 '09 #8
squrel
143 100+
ok i wil try tht
thank u very much for ur help
Jan 2 '09 #9
squrel
143 100+
Hi again..
The code which u have given it to me its just composing the message... how can i set the server in this code... i want the system to send the mail automatically to some people.... i have to set the server and set the name of the persons who wil get the reminder automatically from the system..
can u help me in that???
thank u
Jan 5 '09 #10
debasisdas
8,127 Expert 4TB
you can easily get the list form database and to automate use timer.
Jan 5 '09 #11
squrel
143 100+
ok i can set the timer and get the name of the persons from database... the main problem is how can i set the server ip address and the port number in the code.. do u have any code sample for tht ?
thank u
Jan 5 '09 #12
debasisdas
8,127 Expert 4TB
Which server you are talking about ?

The code that i have passed on to You uses outlook to send mails.

Do you use Outlook ?
Jan 5 '09 #13
squrel
143 100+
i use outlook to send the mail.... bt my reminder has to go to SMTP mail server and from thr it goes to the users.. coz i m not sending the reminder and mail, the system wil send the reminder on a particular date of each month automatically... thts why i need to set the server ip address and the port... i think it should be something like this bt this is for CDO and its not working for MAPI control.. i need to knw how can i set all these for MAPI

With cdoconfig.Fields
.Item(cdoSendUsingMethoD) = 25
.Item(sch & "sendusing") = 80 ' cdoSendUsingPort
.Item(sch & "smtpserver") = "<172.16.1.22>"
.Update
End With

thank u
Jan 5 '09 #14
I have complied the code from #'6 above.

Here is an extract of the statements.

Option Explicit
.
.
.
Dim MAPISession As Object
Dim MAPIMEssages As Object
Dim MAPISession1 As MAPISession
Dim MAPIMEssages1 As MAPIMEssages
.
.
.
Private Sub LogonEmail()

On Error GoTo LogonEmailErr

MAPISession1.SignOn 'Generates error 91.
MAPIMEssages1.SessionID = MAPISession1.SessionID
Exit Sub

LogonEmailErr:
MsgBox ("Error " + Trim(Str(Err)) + " in LogonEmail.")
'etc.
'etc.
End Sub

At the Signon statement I receive error 91 'Object variable or 'WITH' block variable not set'.

So, in order to Set something I added (just before the signon line):

Set MAPISession1 = CreateObject("MAPI.SESSION")

but that causes an error 429: ActiveX component can't create object or return
reference to this object.

If you can assist my inexperience I would be very glad.

Thank you.
Feb 16 '09 #15
Hi guys,

I've been racking my brain with similar issues related to MAPI, which when working to send e-mails is fairly effective, but is extremely fragile. I kept getting Error Code: 48389 run time errors.

I was having a problem signing in to a session

i.e. Form1.MAPISession1.Action = 1

I broke my legacy code down written by predeccessors about 50 pages long, to finally work out a control in vb6 components called 'DatabaseControl' from 'DatabaseControl.ocx' was conflicting with the MAPI controls. My advice to anyone trying to send an e-mail would be to check thier components - especially this one which will not work inconjunction with MAPI. Its best to replace this control with direct SQL statements to access database instead using ADO.


Below is full procedure used to send e-mails:

Expand|Select|Wrap|Line Numbers
  1. Sub SendMail()
  2.       'MAPI constants from CONSTANT.TXT file:
  3.       Const SESSION_SIGNON = 1
  4.       Const MESSAGE_COMPOSE = 6
  5.       Const ATTACHTYPE_DATA = 0
  6.       Const RECIPTYPE_TO = 1
  7.       Const RECIPTYPE_CC = 2
  8.       Const MESSAGE_RESOLVENAME = 13
  9.       Const MESSAGE_SEND = 3
  10.       Const SESSION_SIGNOFF = 2
  11.  
  12.       'Open up a MAPI session:
  13.       Form1.MAPISession1.Action = SESSION_SIGNON
  14.       'Point the MAPI messages control to the open MAPI session:
  15.       Form1.MAPIMessages1.SessionID = Form1.MAPISession1.SessionID
  16.  
  17.       Form1.MAPIMessages1.Action = MESSAGE_COMPOSE   'Start a new message
  18.  
  19.       'Set the subject of the message:
  20.       Form1.MAPIMessages1.MsgSubject = "This is the subject."
  21.       'Set the message content:
  22.       Form1.MAPIMessages1.MsgNoteText = "This is the mail message."
  23.  
  24.       'The following four lines of code add an attachment to the message,
  25.       'and set the character position within the MsgNoteText where the
  26.       'attachment icon will appear. A value of 0 means the attachment will
  27.       'replace the first character in the MsgNoteText. You must have at
  28.       'least one character in the MsgNoteText to be able to attach a file.
  29.       Form1.MAPIMessages1.AttachmentPosition = 0
  30.       'Set the type of attachment:
  31.       Form1.MAPIMessages1.AttachmentType = ATTACHTYPE_DATA
  32.       'Set the icon title of attachment:
  33.       Form1.MAPIMessages1.AttachmentName = "System Configuration File"
  34.       'Set the path and file name of the attachment:
  35.       Form1.MAPIMessages1.AttachmentPathName = "C:\CONFIG.SYS"
  36.  
  37.       'Set the recipients
  38.       Form1.MAPIMessages1.RecipIndex = 0                    'First recipient
  39.       Form1.MAPIMessages1.RecipType = RECIPTYPE_TO          'Recipient in TO line
  40.       Form1.MAPIMessages1.RecipDisplayName = "eddyjawed@yahoo.com"   'e-mail name
  41.       'MAPIMessages1.RecipIndex = 1                  'add a second recipient
  42.       'MAPIMessages1.RecipType = RECIPTYPE_TO        'Recipient in TO line
  43.       'MAPIMessages1.RecipDisplayName = "Tanya Lasagna"     'e-mail name
  44.       'MAPIMessages1.RecipIndex = 2                   'Add a third recipient
  45.       'MAPIMessages1.RecipType = RECIPTYPE_CC         'Recipient in CC line
  46.       'MAPIMessages1.RecipDisplayName = "BlairAngelHair"  'e-mail name
  47.       'MAPIMessages1.RecipIndex = 3                  'Add a fourth recipient
  48.       'MAPIMessages1.RecipType = RECIPTYPE_CC          'Recipient on CC Line
  49.       'MAPIMessages1.RecipDisplayName = "JoanieCannelloni" 'e-mail name"
  50.  
  51.       'MESSAGE_RESOLVENAME checks to ensure the recipient is valid and puts
  52.       'the recipient address in MapiMessages1.RecipAddress
  53.       'If the E-Mail name is not valid, a trappable error will occur.
  54.       Form1.MAPIMessages1.Action = MESSAGE_RESOLVENAME
  55.       'Send the message:
  56.       Form1.MAPIMessages1.Action = MESSAGE_SEND
  57. End Sub
To get this to work, you need to create a form called form1, add a command button and then the two mapi controls ('session' and 'messages')....

Good luck ;)
Oct 15 '09 #16

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Suganthi | last post by:
Hi, I have a specific problem while using MAPI for sending the emails from my application. My requirement is as follows. My application will be running either as a service or a process in a...
4
by: Kurt | last post by:
Hi I am using CDO 1.21 from C# in order to iterate through the entries in a users outlook address book (as OOM was too slow). Basically I take the Name field from each "message" and insert it into...
5
by: eadams | last post by:
I've been tasked with writing an application in VB.Net that will manipulate messages in a user's Inbox. My Exchange admin prefers that I use MAPI; I don't really care, but I want this to be as...
5
by: Larry Bertolini | last post by:
Scenario: DBMS: SQL Server 2000 OS: Windows Server 2003 Goal: Enable SQLMAIL via Internet Mail Problem: How do I set up the MAPI profile for the SQL Server service account?
7
by: Ottar | last post by:
I've made a program sorting incomming mail in public folder. The function runs every minute by using the form.timer event. In Access XP it runs for weeks, no problem. Access 2003 runs the same...
0
by: Selden McCabe | last post by:
I have a VB6 application running on a number of computers at a school. These all have Microsoft Office (and also Outlook) installed. They are using an Exchange server. This app uses the...
3
by: Siv | last post by:
Hi, A little while ago I wrote a small program that allowed the user to view products from a database. The database holds the details of the products which can be viewed via a form and...
2
by: bahog | last post by:
Hi! please help me with my problem. It goes something like this... I am currently developing a visual basic application that can send email using the mapi control and outlook express, my problem is...
1
by: tomer.ha | last post by:
Hi there, I'd like to send emails from a Python program using Simple MAPI. I've tried this code: http://mail.python.org/pipermail/python-list/2004-December/298066.html and it works well with...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.