سلام
با چه کدی میشه برنامه ای ساخت که از کامپیوتر اجرا کننده برنامه ما فایلی (مثلا c:/o.txt) را به ایمیلی فرستاد .
سلام
با چه کدی میشه برنامه ای ساخت که از کامپیوتر اجرا کننده برنامه ما فایلی (مثلا c:/o.txt) را به ایمیلی فرستاد .
این کد اگر میخواهی از ابزارهای ویندوز استفاده کنی خوب است.
Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long
Private Const SW_SHOW = 5
ShellExecute hwnd, "open", "mailto:vbcode@vbcode.com", vbNullString, vbNullString, SW_SHOW
اینم برای حالتی که میخواهی خودت کنترل داشته باشی.
Private Sub SendEmail_Click()
' Geocel DevMailer 1.0
' Visual Basic Usage Example
' (c) 1999, Geocel International, Inc.
'
' - DevMailer can be found at:
' - http://www.geoce.com/devmailer/
' Create DevMailer Object
Set Mailer = CreateObject("Geocel.Mailer")
' Add first SMTP server
Mailer.AddServer DMTestForm.Server_Address, 25
' Set Sender Information
Mailer.FromAddress = DMTestForm.From_Address
Mailer.FromName = "Devmailer Test"
' Add a recipient to the message
Mailer.AddRecipient DMTestForm.To_Address, ""
' Set the Subject and Body
Mailer.Subject = "Welcome to DevMailer"
Mailer.Body = DMTestForm.Message_Body & vbCrLf
' Send Email - Perform Error Checking
bSuccess = Mailer.Send()
If bSuccess = False Then
If Mailer.Queued = False Then
MsgBox ("Could not send message..queueing failed!")
Else
MsgBox ("Could not send message..queued instead!")
End If
Else
MsgBox ("Message Sent Successfully!")
End If
End Sub
Public Function send_mail(sendto As String, subject As String, _
text As String) As Boolean
'Add The MAPI Components and
'add a MAPI Session and MAPI mail control to your form
On Error GoTo ErrHandler
With MAPISession1
.DownLoadMail = False
.LogonUI = True
.SignOn
.NewSession = True
MAPIMessages1.SessionID = .SessionID
End With
With MAPIMessages1
.Compose
.RecipAddress = sendto
.AddressResolveUI = True
.ResolveName
.MsgSubject = subject
.MsgNoteText = text
.Send False
End With
sendmail = True
ErrHandler:
End Function
هیچ کدوم از این دو کد کار نمی کنند چرا؟ :roll: :oops:
این کد ها کار نمیکنه چون object مورد احتاج رو دوستان برای دانلود نزاشتن
برای این منظور به این سایت سر بزن
http://www.geocel.com/devmailer/examples.htm
با سلام این object GeoCel DevMailerپس از 90 روز از کار می افتد(evalution copy)
با سلام این کد با MAPISESSION خودOUTLOOK نوشته شده است چون به هر صورت ما برای فرستادن ایمیل نیاز به Mailserver داریم من در پروژه ای که داشتم از Mailserver داخلی و OutLook استفاده می کردم
این بنظرم مشکل شما را حل می کند امیدوارم مفید واقع شود
Private Function Sendemail(msg)
With MAPISession1
.LogonUI = True
.UserName = strUserName
.Password = strPassword
.SignOn
End With
With MAPIMessages1
.SessionID = MAPISession1.SessionID
.Compose
.MsgNoteText = msg
.RecipAddress = addy
.MsgSubject = "Error In Copiying File"
'.AttachmentPathName = "c:\1.txt"
.ResolveName
.Send
End With
With MAPISession1
.SignOff
End With
End Function
آخرین ویرایش به وسیله houshang.karami : شنبه 29 مرداد 1384 در 13:58 عصر
با سلام
البته دوست عزیز آقای تفرشی نیز از راه MapiSession رفته است