1

Konu: Outlook İle Mail

Outlook ile mail göndermek istiyorum.  Kodlarımı oluşturdum. Outlook açıkken çalışıyor. Ancak Outlook kapalı iken mail gönderemiyorum. Outlooku kapatınca Mail gitmiyor. Müşteriye de önce Outlooku aç demek pek uygun değil. Ne yapabilirim?

Visual Fox Pro
oMail=CreateObject("outlook.application")

oItem = oMail.CreateItem(0)
oItem.Subject = Alltrim(thisform.text1.Value)
 
oItem.To="info@denbil.com"
oItem.Cc = Alltrim(thisform.edit1.Value)
oItem.Body= Alltrim(thisform.edit2.Value)
*oitem.Attachments.Add("c:\deneme.xls")
 
Try 
   oItem.Send
   Wait "Mesaj Gönderimi Başarılı..." window timeout 1
Catch
   Wait "Mesaj Gönderilemedi..." window timeout 1
EndTry
 
oMail=.Null.

2

Re: Outlook İle Mail

gmail yada hotmail servislerini kullanabilirsiniz.

Visual Fox Pro
=SendMailViaLive("soykanozcelik@hotmail.com","XXXXXXXX","blabla@gmail.com","live mail test","deneme mail live.com dan  ")

=SendMailViaGmail("soykanozcelik@gmail.com","XXXXXXXX","blabla@hotmail.com","Gmail mail test","deneme mail gmail.com dan")
 
*------------------------------------------------------------------------------
Function SendMailViaGmail(tcUserName,tcPassword,tcTo,tcSubject,tcBody)
loMail = Newobject("Cdo2000")
With loMail
    .cServer = "smtp.gmail.com"
    .nServerPort = 465 
    .lUseSSL = .T.
 
    .nAuthenticate = 1     && cdoBasic
    .cUserName = m.tcUserName   && "<a href="mailto:yourGmailAccount@gmail.com">yourGmailAccount@gmail.com</a>"
    .cPassword = m.tcPassword  &&"yourGmailPassword"
 
* If From address doesn't match any of the registered identities,
*    Gmail will replace it with your default Gmail address
    .cFrom = .cUserName && "<a href="mailto:yourGmailAccount@gmail.com">yourGmailAccount@gmail.com</a>"
 
    .cTo = m.tcTo && "<a href="mailto:somebody@otherdomain.com">somebody@otherdomain.com</a>, <a href="mailto:somebodyelse@otherdomain.com">somebodyelse@otherdomain.com</a>"
 
    .cSubject = m.tcSubject &&"CDO 2000 email through Gmail SMTP server"
 
* Uncomment next lines to send HTML body
*.cHtmlBody = "<html><body><b>This is an HTML body<br>" + ;
*        "It'll be displayed by most email clients</b></body></html>"
 
.cTextBody = m.tcBody
    *-.cTextBody = "This is a text body." + Chr(13) + Chr(10) + ;
        "It'll be displayed if HTML body is not present or by text only email clients"
 
* Attachments are optional
* .cAttachment = "myreport.pdf, myspreadsheet.xls"
Endwith
 
If loMail.Send() > 0
    For i=1 To loMail.GetErrorCount()
        *-? i, loMail.Geterror(i)
        Messagebox(loMail.Geterror(i))
    Endfor
* Clear errors
    loMail.ClearErrors()
Else
    *-? "Email sent."
    Messagebox("Mail Başarı ile Gönderildi...",64,"Gmail Mail Gönderim",1)
Endif
Endfunc
*------------------------------------------------------------------------------
Function SendMailViaLive(tcUserName,tcPassword,tcTo,tcSubject,tcBody)
 
loMail = Newobject("Cdo2000")
With loMail
    .cServer = "smtp.live.com"
    .nServerPort = 25
    .lUseSSL = .T.
 
    .nAuthenticate = 1     && cdoBasic
    .cUserName =  m.tcUserName   && "<a href="mailto:yourAccount@live.com">yourAccount@live.com</a>"
    .cPassword =  m.tcPassword  &&"yourPassword"
 
*.cFrom = "<a href="mailto:yourlAccount@live.com">yourlAccount@live.com</a>"
 
    .cFrom = .cUserName
 
    .cTo = m.tcTo && "<a href="mailto:somebody@otherdomain.com">somebody@otherdomain.com</a>, <a href="mailto:somebodyelse@otherdomain.com">somebodyelse@otherdomain.com</a>"
 
    .cSubject = m.tcSubject && "CDO 2000 email through MSN SMTP server"
 
* Uncomment next lines to send HTML body
*.cHtmlBody = "<html><body><b>This is an HTML body<br>" + ;
*        "It'll be displayed by most email clients</b></body></html>"
 
.cTextBody = m.tcBody
    *-.cTextBody = "This is a text body." + Chr(13) + Chr(10) + ;
        "It'll be displayed if HTML body is not present or by text only email clients"
 
* Attachments are optional
* .cAttachment = "myreport.pdf, myspreadsheet.xls"
Endwith
 
If loMail.Send() > 0
    For i=1 To loMail.GetErrorCount()
*-? i, loMail.Geterror(i)
        Messagebox(loMail.Geterror(i))
    Endfor
* Clear errors
    loMail.ClearErrors()
Else
*-? "Email sent."
    Messagebox("Mail Başarı ile Gönderildi...",64,"Live Mail Gönderim",1)
Endif
 
Endfunc
 
*--------------------------------------------------------
#Define cdoSendPassword "http://schemas.microsoft.com/cdo/configuration/sendpassword"
#Define cdoSendUserName "http://schemas.microsoft.com/cdo/configuration/sendusername"
#Define cdoSendUsingMethod "http://schemas.microsoft.com/cdo/configuration/sendusing"
#Define cdoSMTPAuthenticate "http://schemas.microsoft.com/cdo/configuration/smtpauthenticate"
#Define cdoSMTPConnectionTimeout "http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout"
#Define cdoSMTPServer "http://schemas.microsoft.com/cdo/configuration/smtpserver"
#Define cdoSMTPServerPort "http://schemas.microsoft.com/cdo/configuration/smtpserverport"
#Define cdoSMTPUseSSL "http://schemas.microsoft.com/cdo/configuration/smtpusessl"
#Define cdoURLGetLatestVersion "http://schemas.microsoft.com/cdo/configuration/urlgetlatestversion"
#Define cdoAnonymous 0    && Perform no authentication (anonymous)
#Define cdoBasic 1    && Use the basic (clear text) authentication mechanism.
#Define cdoSendUsingPort 2    && Send the message using the SMTP protocol over the network.
#Define cdoXMailer "urn:schemas:mailheader:x-mailer"
 
Define Class cdo2000 As Custom
 
    Protected aErrors[1], nErrorCount, oMsg, oCfg, cXMailer
 
    nErrorCount = 0
 
* Message attributes
    oMsg = Null
    cFrom = ""
    cReplyTo = ""
    cTo = ""
    cCC = ""
    cBCC = ""
    cAttachment = ""
 
    cSubject = ""
    cHtmlBody = ""
    cTextBody = ""
    cHtmlBodyUrl = ""
 
    cCharset = ""
 
* Configuration object fields values
    oCfg = Null
    cServer = ""
    nServerPort = 25
* Use SSL connection
    lUseSSL = .F.
    nConnectionTimeout = 30            && Default 30 sec's
    nAuthenticate = cdoAnonymous
    cUserName = ""
    cPassword = ""
* Do not use cache for cHtmlBodyUrl
    lURLGetLatestVersion = .T.
 
* Optional. Creates your own X-MAILER field in the header
    cXMailer = "VFP CDO 2000(CDOSYS) mailer Ver 1.1 2009"
 
    Protected Procedure Init
        This.aErrors = Null
        Endproc
 
* Send message
    Procedure Send
 
    With This
        .ClearErrors()
        .oCfg = Createobject("CDO.Configuration")
        .oMsg = Createobject("CDO.Message")
        .oMsg.Configuration = This.oCfg
    Endwith
 
* Fill message attributes
    Local lnind, laList[1], loHeader, laDummy[1]
 
    If This.SetConfiguration() > 0
        Return This.GetErrorCount()
    Endif
 
    If Empty(This.cFrom)
        This.AddError("HATA : Kimden kısmı boş!")
    Endif
    If Empty(This.cSubject)
        This.AddError("HATA : Konu kısmı boş!")
    Endif
 
    If Empty(This.cTo) And Empty(This.cCC) And Empty(cBCC)
        This.AddError("HATA : Kime,Karbon Kopya ve Gizli Karbon Kopya alanları boş!")
    Endif
 
    If This.GetErrorCount() > 0
        Return This.GetErrorCount()
    Endif
 
    This.SetHeader()
 
    With This.oMsg
 
        .From     = This.cFrom
        .ReplyTo  = This.cReplyTo
 
        .To       = This.cTo
        .CC       = This.cCC
        .BCC      = This.cBCC
        .Subject  = This.cSubject
 
* Create HTML body from external HTML (file, URL)
        If Not Empty(This.cHtmlBodyUrl)
            .CreateMHTMLBody(This.cHtmlBodyUrl)
        Endif
 
* Send HTML body. Creates TextBody as well
        If Not Empty(This.cHtmlBody)
            .HtmlBody = This.cHtmlBody
        Endif
 
* Send Text body. Could be different from HtmlBody, if any
        If Not Empty(This.cTextBody)
            .TextBody = This.cTextBody
        Endif
 
        If Not Empty(.HtmlBody)
            .HtmlBodyPart.Charset = This.cCharset
        Endif
 
        If Not Empty(.TextBody)
            .TextBodyPart.Charset = This.cCharset
        Endif
 
* Process attachments
        If Not Empty(This.cAttachment)
* Accepts comma or semicolon
* VFP 7.0 and later
*FOR lnind=1 TO ALINES(laList, This.cAttachment, [,], [;]<