Click here to Skip to main content
15,892,697 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Dear Sir


I am sending mail from vb 6 using my gmail account with excel attached file to my another account in outlook but it shows my .xls.dat file and in my sent items of gmail it also not open as excel file.
i am using this following code


Set mg = CreateObject("CDO.Message")
Set iConf = CreateObject("CDO.Configuration")
Set fn = iConf.Fields
schema = "http://schemas.microsoft.com/cdo/configuration/"
fn.Item(schema & "sendusing") = 2

fn.Item(schema & "smtpserver") = Text4.Text "smtp.gmail.com"
fn.Item(schema & "smtpserverport") = Text3.Text '25 ' 465
fn.Item(schema & "smtpauthenticate") = 1
fn.Item(schema & "sendusername") = "" & Trim(Text1.Text) & ""
fn.Item(schema & "sendpassword") = "" & Trim(Text2.Text) & ""

With mg
.To = txtto
'.To = "" & res("email") & ""
.From = " <br><" & Trim(Text1.Text) & "><br>"
.Subject = "Sub: Quotation For the supply of CARTONS with respect of following specification:<br>"



FILELP1 ="D\file.xls"
.Organization = "Duke Infosys"
If FILELP1 <> "" Then
.AddAttachment "" & FILELP1 & " "
End If
.ReplyTo = "" & Trim(Text1.Text) & ""
Set .Configuration = iConf
SendEmailGmail = .send
End With
Posted
Comments
Sergey Alexandrovich Kryukov 29-Jan-15 1:07am    
Any particular reason to suffer from VB6?
—SA

1 solution

"D\file.xls" is not a valid file name - change that to a proper file name.

Also consider using Dir to confirm the file exists before trying to attach it
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900