VB School Assignment? Project Due Tomorrow? Chat LIVE With A Programming Expert!

Welcome to Dream.In.Code
Become a VB Expert!

Join 307,090 VB Programmers for FREE! Get instant access to thousands of VB experts, tutorials, code snippets, and more! There are 2,036 people online right now. Registration is fast and FREE... Join Now!




How to send a mail with attach a file

 

How to send a mail with attach a file, This code send a mail but not send attach file so please rectify the p

muthuganesh

5 Nov, 2009 - 11:35 PM
Post #1

New D.I.C Head
*

Joined: 30 Sep, 2009
Posts: 1

CODE

Public Sub sendmail()
Dim imsg As Object
Dim iconf As Object
Dim fields As Variant

Set imsg = CreateObject("CDO.Message")
Set iconf = CreateObject("CDO.Configuration")

iconf.Load -1 ' CDO Source Defaults
Set Flds = iconf.fields
With Flds
.Item("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = True
.Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1
.Item("http://schemas.microsoft.com/cdo/configuration/sendusername") = "from ID"
.Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "Password"
.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "smtp.gmail.com"
.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
.Update
End With
strbody = Message
attachFile = txtAttach.Text

With imsg
Set .Configuration = iconf
.To = "To Id"
.CC = ""
.BCC = ""
.From = "from ID"
.Subject = "Subject"
.Attachement = (attachFile)
.TextBody = strbody
.Send


End With

End Sub


User is offlineProfile CardPM
+Quote Post


MajorWalrus

RE: How To Send A Mail With Attach A File

6 Nov, 2009 - 06:29 AM
Post #2

D.I.C Head
**

Joined: 22 Apr, 2009
Posts: 98



Thanked: 9 times
My Contributions
Two thoughts. First, you have declared attachFile, that could be part of the problem. Try declaring it as an attachment. Second, I'd make sure there is a file called txtAttach.Text on your system. You might want to try specifying the complete path.

Good luck.
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic

Time is now: 11/21/09 11:28AM

Live VB Help!

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter Fan Us On Facebook

VB Tutorials

Reference Sheets

VB Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month