Author | Topic: Send mail to MS Outlook | |
---|---|---|
Toma Grom | Send mail to MS Outlook on Thu, 06 Mar 2008 14:32:44 +0100 Hello! I got a procedure for sending email via outlook on this newsgroups, and I have a little problem. Everything works ok, and the email dialog is displayed ok including attachments, but i get an errormessage like this: Operating system error: 1 - it means Incorrect function Operation: display If I remove the :display() method call, there is no error any more, but also no effect (no attachment) ... Is tehre any other method, that woudl not be bound to ceratin default mailer ? Here is a procedure I use: ********************************************************************** PROCEDURE SendMailToOutlook( cSubject, cBody, acFile, acEmail ) ********************************************************************** #pragma library( "ascom10.lib" ) LOCAL oOutlook := CreateObject( "Outlook.Application" ) LOCAL i, oMessage, olMailItem, oNS IF empty(oOutlook) MsgBox( "Cannot access Outlook application. Please make sure MS Outlook is" + Chr(13) + Chr(10) +; "correctly installed on your computer.", "Error" ) return ENDIF IF Valtype(acFile) = 'C' acFile := { acFile } ENDIF IF Valtype(acEmail) = 'C' acEmail := { acEmail } ENDIF oNS := oOutlook:GetNamespace( "MAPI" ) oMessage := oOutlook:CreateItem(0) //olMailItem oMessage:subject := cSubject oMessage:HtmlBody := cBody Setting the new MailItem recipients FOR i := 1 TO Len(acEmail) oMessage:Recipients:Add(acEmail[i]) NEXT Dc_debugqout(acFile) Adding the new MailItem a file attachment IF acfile != nil FOR i := 1 TO Len(acFile) oMessage:Attachments:Add(acFile[i]) NEXT ENDIF oMessage:display() oMessage:destroy() oOutlook:destroy() RETURN | |
Wolfgang Ciriack | Re: Send mail to MS Outlook on Thu, 06 Mar 2008 19:09:12 +0100 Hi Tomas, i don't no if this helps, but in the helpdoc of outlook stands: object.Display(Modal As Variant) Regards Wolfgang | |
Toma Grom | Re: Send mail to MS Outlook on Sat, 08 Mar 2008 14:49:21 +0100 Thank you, Wolfgang. I tried it bu unfortunateljy without success. Best regards Toma | |
Osvaldo Luis Aoki | Re: Send mail to MS Outlook on Wed, 28 Jul 2010 16:27:32 -0300 Hi, The function below works fine, but only for one email, but you have to do a quick modify to work,.. oOutlook := CreateObject( "Outlook.Application" ) if empty(oOutlook) MSGBOX('NÆo foi encontrado o OutLook/Calend rio !') RETURN(.F.) endif oItem := oOutlook:CreateItem( olMailItem ) oItem:treatDateAsString(.t.) oiTem:SetProperty("to", cTo ) if cBcc <> nil oItem:BCC := cBcc endif if cCC <> nil oItem:CC := cCC endif if cAttach <> nil oItem:Attachments:Add(cAttach) endif cMsg += crlf + crLf cMsg += replicate("-", 100) + crLF cMsg += "[ Email enviado por E2Corp - User: " + trim(s_usNome) + " - " + dtoc(date()) + "-" + time() + " ] " + crLF oItem:Subject := cSubject oItem:Body := cMsg oItem:Save() oItem:Send() oOutLook:destroy() oOutLook:= nil oItem := nil "Toma¾ Grom" <tomaz.grom@siol.net> escreveu na mensagem news:2466218f$45aa726e$4b5c@news.alaska-software.com... > Hello! > I got a procedure for sending email via outlook on this newsgroups, and I > have a little problem. > Everything works ok, and the email dialog is displayed ok including > attachments, but i get an errormessage like this: > > Operating system error: 1 - it means Incorrect function > Operation: display > > If I remove the :display() method call, there is no error any more, but > also no effect (no attachment) ... > > Is tehre any other method, that woudl not be bound to ceratin default > mailer ? > > Here is a procedure I use: > > ********************************************************************** > PROCEDURE SendMailToOutlook( cSubject, cBody, acFile, acEmail ) > ********************************************************************** > #pragma library( "ascom10.lib" ) > > LOCAL oOutlook := CreateObject( "Outlook.Application" ) > LOCAL i, oMessage, olMailItem, oNS > > IF empty(oOutlook) > MsgBox( "Cannot access Outlook application. Please make sure MS Outlook > is" + Chr(13) + Chr(10) +; > "correctly installed on your computer.", "Error" ) > return > ENDIF > > IF Valtype(acFile) = 'C' > acFile := { acFile } > ENDIF > > IF Valtype(acEmail) = 'C' > acEmail := { acEmail } > ENDIF > > oNS := oOutlook:GetNamespace( "MAPI" ) > oMessage := oOutlook:CreateItem(0) //olMailItem > oMessage:subject := cSubject > oMessage:HtmlBody := cBody > > Setting the new MailItem recipients > FOR i := 1 TO Len(acEmail) > oMessage:Recipients:Add(acEmail[i]) > NEXT > > Dc_debugqout(acFile) > Adding the new MailItem a file attachment > IF acfile != nil > FOR i := 1 TO Len(acFile) > oMessage:Attachments:Add(acFile[i]) > NEXT > ENDIF > > oMessage:display() > > oMessage:destroy() > oOutlook:destroy() > RETURN > |