Predmet:Re: Send Maill
dragi prijatelju!
i ja sam se namucio sa time no nakon godina mukotrpnog istrazivanja uspio sam poslati mail iz VB6.
Na internetu ima jako puno primjera i svi su u srži isti i rade na istom principu, a razlikuju se u dizajnu koda.
Primjer1. Ovo radi kod mene 100%
Ovo je jedan jednostavni kod
PreuzmiIzvorni kôd (Visual Basic):Private Sub Command1_Click()
Call SendGMail
End Sub
Sub SendGMail()
' Object creation
Set objMsg = CreateObject("CDO.Message")
Set msgConf = CreateObject("CDO.Configuration")
' Server Configuration
msgConf.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
msgConf.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "smtp.gmail.com"
msgConf.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 465
msgConf.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1
msgConf.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusername") = "tvoj.mail@gmail.com"
msgConf.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "lozinka"
msgConf.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = 1
msgConf.Fields.Update
' Email
objMsg.To = "kome.saljes@gmail.com"
objMsg.From = "tvoj.mail@gmail.com"
objMsg.Subject = "naslov u poruci"
objMsg.HTMLBody = "tekst poruke"
objMsg.Sender = "Mr. Name"
Set objMsg.Configuration = msgConf
' Send
objMsg.Send
' Clear
Set objMsg = Nothing
Set msgConf = Nothing
End Sub
Netko koristi umjesto procedure sendGMail,
funkciju sendGMail( "kome.saljes@gmail.com","tvoj.mail@gmail.com", "naslov u poruci","tekst poruke","Mr. Name")
primjer2. evo isti taj primjer (isto govno drugo pakovanje)
PreuzmiIzvorni kôd (Visual Basic):Private Sub SendEmail(strEmail, strEpass, strSendTo, strSubject, strTextBody , Optional strAttachment As String)
Dim objCDOMsg As New CDO.Message
Dim objCDOCon As New CDO.Configuration
Dim strSchemas As String
strSchemas = "http://schemas.microsoft.com/cdo/configuration/"
With objCDOCon.Fields
.Item(strSchemas & "sendusing") = 2
.Item(strSchemas & "smtpserver") = "smtp.gmail.com"
.Item(strSchemas & "smtpserverport") = 465
.Item(strSchemas & "smtpauthenticate") = 1
.Item(strSchemas & "sendusername") = strEmail ' Your gmail
.Item(strSchemas & "sendpassword") = strEpass ' Your password
.Item(strSchemas & "smtpconnectiontimeout") = 30
.Item(strSchemas & "smtpusessl") = 1
.Update
End With
' Construct your email
With objCDOMsg
.From = strEmail ' Your Email
.To = strSendTo ' Send to any email (example: example@yahoo.com)
.Subject = strSubject ' Subject
.TextBody = strTextBody ' Body
.Sender = strEmail ' Your Email
.ReplyTo = strEmail ' Your Email
.AddAttachment strAttachment ' Your Attachment
Set .Configuration = objCDOCon
.Send ' Send Email
End With
End Sub
VAZNO:
Da bi ti ovo radilo moras napraviti dvije(2) stvari:
1. u Project-Reference ukljuciti Microsoft CDO for windows 2000 library
2. moras u gmailu na sigurnosti uklkjuciti na ON inace ti nece raditi kao ni meni.
nakon sto posjetis ovaj link
https://www.google.com/...secureapps
ispisati ce ti se tekst :
Some apps and devices use less secure sign-in technology, which makes your account more vulnerable. You can turn off access for these apps, which we recommend, or turn on access if you want to use them despite the risks.
a onda izaberes ON i dozvolices svojoj "sumnjivoj" aplikaciji da pristupi tvome racunu i uz pomoc smtp.gmail.com protokola posalje mail nekoj drugoj osobi
nadam se da sam ti pomogao, stavio sam i program da nemoras prepisivati.
vidis kako sam dobar, aaa? sta kaze?
jesam li zasluzio pseći kolačić?
mmmm, av-av
Prilozi:
sendGmail.rar
Preuzimanja:388
Velicina datoteke:1.56 KB
zivot je moja domovina.