Computing.Net > Forums > Programming > error on outlook program (VC)

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

error on outlook program (VC)

Reply to Message Icon

Name: sakai111
Date: August 16, 2008 at 22:10:15 Pacific
OS: XP
CPU/Ram: Dual core
Product: dell
Comment:

I copy the program to use the outlook function in VC6 software. When I run the program, it can not get the pointer of the outlook.
the error is :"CreateDispatch failed()w/error 0x800401f3". I don't know what mean by this and where I should put the exe file to run.
There is the code below:

_Application olApp;
COleException e;
if(!olApp.CreateDispatch("Outlook", &e)) {
CString str;
str.Format("CreateDispatch() failed w/error 0x%08lx", e.m_sc);
AfxMessageBox(str, MB_SETFOREGROUND);
return;
}

// Logon. Doesn't hurt if you are already running and logged on...
_NameSpace olNs(olApp.GetNamespace("MAPI"));
COleVariant covOptional((long)DISP_E_PARAMNOTFOUND, VT_ERROR);
olNs.Logon(covOptional, covOptional, covOptional, covOptional);

// Create and open a new contact
_ContactItem olItem(olApp.CreateItem(2));

// Setup Contact information...
olItem.SetFullName("James Smith");
COleDateTime bdDate;
bdDate.SetDate(1975, 9, 15);
olItem.SetBirthday(bdDate);
olItem.SetCompanyName("Microsoft");
olItem.SetHomeTelephoneNumber("704-555-8888");
olItem.SetEmail1Address("sakai111w@yahoo.com");
olItem.SetJobTitle("Developer");
olItem.SetHomeAddress("111 Main St.\nCharlotte, NC 28226");

// Save Contact
olItem.Save();

// Create a new appointment
_AppointmentItem olAppt(olApp.CreateItem(1));

// Schedule it for two minutes from now...
COleDateTime apptDate = COleDateTime::GetCurrentTime();
olAppt.SetStart((DATE)apptDate + DATE(2.0/(24.0*60.0)));

// Set other appointment info...
olAppt.SetDuration(60);
olAppt.SetSubject("Meeting to discuss plans...");

olAppt.SetBody("Meeting with James to discuss plans.");
olAppt.SetLocation("Home Office");
olAppt.SetReminderMinutesBeforeStart(1);
olAppt.SetReminderSet(TRUE);

// Save Appointment
olAppt.Save();

// Prepare a new mail message
_MailItem olMail(olApp.CreateItem(0));
olMail.SetTo("someone@microsoft.com");
olMail.SetSubject("About our meeting...");
olMail.SetBody(
"Hi James,\n\n"
"\tI'll see you in two minutes for our meeting!\n\n"
"Btw: I've added you to my contact list!");

// Send the message!
olMail.Send();

AfxMessageBox("All done.", MB_SETFOREGROUND);
olNs.Logoff();



Sponsored Link
Ads by Google

Response Number 1
Name: Razor2.3
Date: August 17, 2008 at 19:28:11 Pacific
Reply:

Try

if(!olApp.CreateDispatch(OLESTR("Outlook"), &e)) {

Assuming .CreateDispatch doesn't require a CSLID (vs. a name).


0

Response Number 2
Name: sakai111
Date: August 22, 2008 at 20:30:17 Pacific
Reply:

Hi,

When I try to compile the program, it give me the error. The error below:

SendEmailView.cpp
C:\Documents and Settings\Regina\Desktop\Ian\SendEmail\SendEmailView.cpp(97) : error C2664: 'int __thiscall COleDispatchDriver::CreateDispatch(const struct _GUID &,class COleException *)' : cannot convert parameter 1 from 'unsigned short [8]' to 'co
nst struct _GUID &'
Reason: cannot convert from 'unsigned short [8]' to 'const struct _GUID'
No constructor could take the source type, or constructor overload resolution was ambiguous
Error executing cl.exe.

SendEmail.exe - 1 error(s), 0 warning(s)

Thank you


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: error on outlook program (VC)

How do I work on outlook pst file www.computing.net/answers/programming/how-do-i-work-on-outlook-pst-file/11334.html

Help on java program www.computing.net/answers/programming/help-on-java-program/7078.html

C prototype errors on compile www.computing.net/answers/programming/c-prototype-errors-on-compile/1536.html