Outlook 2007 lose the attatchment when sending through external sc

F

Fredrik

Hi.
I have an application where I am able to send a report that I've exported to
an pdf.
I plase the pdf-file in temp-dir and attatch it via an vbscript that calls
Outlook 2007.

It works just fine when it is displayd on the screen. The attatched file is
there and everything. But when I click on send, the recipient will not get
the file. The mail itselfs get through but not the attached file.
I have my own mailserver and can look in the logs and there I see that the
attached file is'nt there.

If I create a new mail inside ol2k7 and attach the same file that is droped
in temp-dir and then send it, it works just fine.
I'm not sure but my guesse is that there is som security glitch in ol2k7
that stops the file to be sent. Is that possible? And how do I work around it?

The same code works without any problems on ol2k3.

Realy thanks in advance.
 
D

Dmitry Streblechenko

Do you see the attachments when you look at the message in the Sent Items
folder?

--
Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
-
 
F

Fredrik

Yes I do. When I look in the Sent Items folder it has been sent with the
attached file. It's there and it is correct size and everything should work.
The recipient that is getting the mail with the attatched file has ol2k3.
Can it be becaus of that?
I have'nt had a chanse to try to an other recpient yet, that use ol2k7.
I think it's rather strange if that would be the case here.
I have tried some stuff now to and now when I look in the logs at the
mailserver I can see that the mail is in the correct size now. But it is
02:40 here now so I'll have to see tomorrow if the mail has arrived with the
attached file.

One thing I might add is that I don't send the mail via the vbscript. Iäm
letting the user see the mail and can write more info in the mail before
he/she sends it by clicking on send.

Thanks for your answeer.
 
F

Fredrik

Okey. Feel that I have to add more info.

I just tried to see if the attached file will show up on hotmail. And it does.
Then I am pretty chor about the file is sent aswell.

What is the different between adding a attachment by hand on Outlook 2007
and by adding it by script?
And what is the different in between, what is the different between adding a
attachment by hand on Outlook 2003 and by adding it by script?

The code I am using is as following:

Const olMailItem = 0
Const olOriginator = 0
Const olByReference = 4
Const olByValue = 1
Const olEmbeddedItem = 5
Dim Outlook
Dim Message
Dim olFolderOutbox
Dim olFolderDrafts
Dim GetArgs
Dim I

olFolderOutbox = 4
olFolderDrafts = 16

On Error Resume Next
Set Outlook = GetObject(, "Outlook.Application")
If Outlook Is Nothing Then
Set Outlook = CreateObject("Outlook.Application")
End If
Err.Clear
On Error Goto 0

Set Message = Outlook.GetNameSpace("MAPI")._
GetDefaultFolder(olFolderDrafts)._
Items.Add("IPM.[Standard Forms Library].Message")

With Message
GetArgs = ""
GetArg "subject", GetArgs
.Subject = GetArgs

GetArgs = ""
GetArg "to", GetArgs
.Recipients.Add (GetArgs)

GetArgs = ""
GetArg "body", GetArgs
If Len(GetArgs) > 0 Then .Body = GetArgs

GetArgs = ""
GetArg "cc", GetArgs
If Len(GetArgs) > 0 Then .Cc = GetArgs

GetArgs = ""
GetArg "bcc", GetArgs
If Len(GetArgs) > 0 Then .Bcc = GetArgs

GetArgs = ""
GetArg "from", GetArgs
If Len(GetArgs) > 0 Then .Recipients.Add(GetArgs).Type = olOriginator
.Recipients.ResolveAll

.Save

For I = 1 To 5
GetArgs = ""
GetArg "attach" & CStr(I), GetArgs
If Len(GetArgs) > 0 Then
.attachments.Add GetArgs, 1, I
End If
Next

.Display
End With

Set Message = Nothing
Set Outlook = Nothing

'-----------------------------------------------------
' Checks the command line arguments for a given switch and returns the
associated
' string, if found. If not found, the defaultValue is returned instead.
Function GetArg( sSwitch, sDefaultValue )
Dim ArgCount, bMatch

ArgCount = 0
bMatch = 0

Do While ArgCount < WScript.arguments.length
If Eval((WScript.arguments.item(ArgCount)) = ("-" + (sSwitch))) Or
Eval((WScript.arguments.item(ArgCount)) = ("/" + (sSwitch))) Then
bMatch = 1
Exit do
Else
ArgCount = ArgCount + 1
End If
Loop

If ( bMatch = 1 ) Then
GetArgs = ( WScript.arguments.item(ArgCount + 1) )
Else
GetArgs = ( sDefaultValue )
End If

End Function


I'm not getting any errors at all. It all works just fine. But what am I
missing?

Thanks in advance
 
D

Dmitry Streblechenko

If you are sending in the RTF format (which is very likely since you havea
custom message class), you will get the infamous winmail.dat attachment with
teh TNEF data, which only Outlook can understand.
Try to send a message to an account taht yo ucan access with OE and then
look at the meaasge source (*right click, Properties| Details | Message
Source).
--
Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
-
Fredrik said:
Okey. Feel that I have to add more info.

I just tried to see if the attached file will show up on hotmail. And it
does.
Then I am pretty chor about the file is sent aswell.

What is the different between adding a attachment by hand on Outlook 2007
and by adding it by script?
And what is the different in between, what is the different between adding
a
attachment by hand on Outlook 2003 and by adding it by script?

The code I am using is as following:

Const olMailItem = 0
Const olOriginator = 0
Const olByReference = 4
Const olByValue = 1
Const olEmbeddedItem = 5
Dim Outlook
Dim Message
Dim olFolderOutbox
Dim olFolderDrafts
Dim GetArgs
Dim I

olFolderOutbox = 4
olFolderDrafts = 16

On Error Resume Next
Set Outlook = GetObject(, "Outlook.Application")
If Outlook Is Nothing Then
Set Outlook = CreateObject("Outlook.Application")
End If
Err.Clear
On Error Goto 0

Set Message = Outlook.GetNameSpace("MAPI")._
GetDefaultFolder(olFolderDrafts)._
Items.Add("IPM.[Standard Forms Library].Message")

With Message
GetArgs = ""
GetArg "subject", GetArgs
.Subject = GetArgs

GetArgs = ""
GetArg "to", GetArgs
.Recipients.Add (GetArgs)

GetArgs = ""
GetArg "body", GetArgs
If Len(GetArgs) > 0 Then .Body = GetArgs

GetArgs = ""
GetArg "cc", GetArgs
If Len(GetArgs) > 0 Then .Cc = GetArgs

GetArgs = ""
GetArg "bcc", GetArgs
If Len(GetArgs) > 0 Then .Bcc = GetArgs

GetArgs = ""
GetArg "from", GetArgs
If Len(GetArgs) > 0 Then .Recipients.Add(GetArgs).Type = olOriginator
.Recipients.ResolveAll

.Save

For I = 1 To 5
GetArgs = ""
GetArg "attach" & CStr(I), GetArgs
If Len(GetArgs) > 0 Then
.attachments.Add GetArgs, 1, I
End If
Next

.Display
End With

Set Message = Nothing
Set Outlook = Nothing

'-----------------------------------------------------
' Checks the command line arguments for a given switch and returns the
associated
' string, if found. If not found, the defaultValue is returned instead.
Function GetArg( sSwitch, sDefaultValue )
Dim ArgCount, bMatch

ArgCount = 0
bMatch = 0

Do While ArgCount < WScript.arguments.length
If Eval((WScript.arguments.item(ArgCount)) = ("-" + (sSwitch))) Or
Eval((WScript.arguments.item(ArgCount)) = ("/" + (sSwitch))) Then
bMatch = 1
Exit do
Else
ArgCount = ArgCount + 1
End If
Loop

If ( bMatch = 1 ) Then
GetArgs = ( WScript.arguments.item(ArgCount + 1) )
Else
GetArgs = ( sDefaultValue )
End If

End Function


I'm not getting any errors at all. It all works just fine. But what am I
missing?

Thanks in advance
 
F

Fredrik

But if that is correct.. How come that users with Outlook 2003 does'nt get
the attachment either? And how come that hotmail works???

I will ofcourse try to do what you say.. :)

Dmitry Streblechenko said:
If you are sending in the RTF format (which is very likely since you havea
custom message class), you will get the infamous winmail.dat attachment with
teh TNEF data, which only Outlook can understand.
Try to send a message to an account taht yo ucan access with OE and then
look at the meaasge source (*right click, Properties| Details | Message
Source).
--
Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
-
Fredrik said:
Okey. Feel that I have to add more info.

I just tried to see if the attached file will show up on hotmail. And it
does.
Then I am pretty chor about the file is sent aswell.

What is the different between adding a attachment by hand on Outlook 2007
and by adding it by script?
And what is the different in between, what is the different between adding
a
attachment by hand on Outlook 2003 and by adding it by script?

The code I am using is as following:

Const olMailItem = 0
Const olOriginator = 0
Const olByReference = 4
Const olByValue = 1
Const olEmbeddedItem = 5
Dim Outlook
Dim Message
Dim olFolderOutbox
Dim olFolderDrafts
Dim GetArgs
Dim I

olFolderOutbox = 4
olFolderDrafts = 16

On Error Resume Next
Set Outlook = GetObject(, "Outlook.Application")
If Outlook Is Nothing Then
Set Outlook = CreateObject("Outlook.Application")
End If
Err.Clear
On Error Goto 0

Set Message = Outlook.GetNameSpace("MAPI")._
GetDefaultFolder(olFolderDrafts)._
Items.Add("IPM.[Standard Forms Library].Message")

With Message
GetArgs = ""
GetArg "subject", GetArgs
.Subject = GetArgs

GetArgs = ""
GetArg "to", GetArgs
.Recipients.Add (GetArgs)

GetArgs = ""
GetArg "body", GetArgs
If Len(GetArgs) > 0 Then .Body = GetArgs

GetArgs = ""
GetArg "cc", GetArgs
If Len(GetArgs) > 0 Then .Cc = GetArgs

GetArgs = ""
GetArg "bcc", GetArgs
If Len(GetArgs) > 0 Then .Bcc = GetArgs

GetArgs = ""
GetArg "from", GetArgs
If Len(GetArgs) > 0 Then .Recipients.Add(GetArgs).Type = olOriginator
.Recipients.ResolveAll

.Save

For I = 1 To 5
GetArgs = ""
GetArg "attach" & CStr(I), GetArgs
If Len(GetArgs) > 0 Then
.attachments.Add GetArgs, 1, I
End If
Next

.Display
End With

Set Message = Nothing
Set Outlook = Nothing

'-----------------------------------------------------
' Checks the command line arguments for a given switch and returns the
associated
' string, if found. If not found, the defaultValue is returned instead.
Function GetArg( sSwitch, sDefaultValue )
Dim ArgCount, bMatch

ArgCount = 0
bMatch = 0

Do While ArgCount < WScript.arguments.length
If Eval((WScript.arguments.item(ArgCount)) = ("-" + (sSwitch))) Or
Eval((WScript.arguments.item(ArgCount)) = ("/" + (sSwitch))) Then
bMatch = 1
Exit do
Else
ArgCount = ArgCount + 1
End If
Loop

If ( bMatch = 1 ) Then
GetArgs = ( WScript.arguments.item(ArgCount + 1) )
Else
GetArgs = ( sDefaultValue )
End If

End Function


I'm not getting any errors at all. It all works just fine. But what am I
missing?

Thanks in advance


.
 
F

Fredrik

Ahh.. I see what you mean..
But how do I change on that? The thing is that we have alot of costumers
that is useing this application and one of them is about 40 workers that uses
this code.
And trust me. I wont go araound to everyone and change any settings in
outlook to get this to work.. *LOL*
So can I by any chance change my code so it is the correct mimes and so on?

Dmitry Streblechenko said:
If you are sending in the RTF format (which is very likely since you havea
custom message class), you will get the infamous winmail.dat attachment with
teh TNEF data, which only Outlook can understand.
Try to send a message to an account taht yo ucan access with OE and then
look at the meaasge source (*right click, Properties| Details | Message
Source).
--
Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
-
Fredrik said:
Okey. Feel that I have to add more info.

I just tried to see if the attached file will show up on hotmail. And it
does.
Then I am pretty chor about the file is sent aswell.

What is the different between adding a attachment by hand on Outlook 2007
and by adding it by script?
And what is the different in between, what is the different between adding
a
attachment by hand on Outlook 2003 and by adding it by script?

The code I am using is as following:

Const olMailItem = 0
Const olOriginator = 0
Const olByReference = 4
Const olByValue = 1
Const olEmbeddedItem = 5
Dim Outlook
Dim Message
Dim olFolderOutbox
Dim olFolderDrafts
Dim GetArgs
Dim I

olFolderOutbox = 4
olFolderDrafts = 16

On Error Resume Next
Set Outlook = GetObject(, "Outlook.Application")
If Outlook Is Nothing Then
Set Outlook = CreateObject("Outlook.Application")
End If
Err.Clear
On Error Goto 0

Set Message = Outlook.GetNameSpace("MAPI")._
GetDefaultFolder(olFolderDrafts)._
Items.Add("IPM.[Standard Forms Library].Message")

With Message
GetArgs = ""
GetArg "subject", GetArgs
.Subject = GetArgs

GetArgs = ""
GetArg "to", GetArgs
.Recipients.Add (GetArgs)

GetArgs = ""
GetArg "body", GetArgs
If Len(GetArgs) > 0 Then .Body = GetArgs

GetArgs = ""
GetArg "cc", GetArgs
If Len(GetArgs) > 0 Then .Cc = GetArgs

GetArgs = ""
GetArg "bcc", GetArgs
If Len(GetArgs) > 0 Then .Bcc = GetArgs

GetArgs = ""
GetArg "from", GetArgs
If Len(GetArgs) > 0 Then .Recipients.Add(GetArgs).Type = olOriginator
.Recipients.ResolveAll

.Save

For I = 1 To 5
GetArgs = ""
GetArg "attach" & CStr(I), GetArgs
If Len(GetArgs) > 0 Then
.attachments.Add GetArgs, 1, I
End If
Next

.Display
End With

Set Message = Nothing
Set Outlook = Nothing

'-----------------------------------------------------
' Checks the command line arguments for a given switch and returns the
associated
' string, if found. If not found, the defaultValue is returned instead.
Function GetArg( sSwitch, sDefaultValue )
Dim ArgCount, bMatch

ArgCount = 0
bMatch = 0

Do While ArgCount < WScript.arguments.length
If Eval((WScript.arguments.item(ArgCount)) = ("-" + (sSwitch))) Or
Eval((WScript.arguments.item(ArgCount)) = ("/" + (sSwitch))) Then
bMatch = 1
Exit do
Else
ArgCount = ArgCount + 1
End If
Loop

If ( bMatch = 1 ) Then
GetArgs = ( WScript.arguments.item(ArgCount + 1) )
Else
GetArgs = ( sDefaultValue )
End If

End Function


I'm not getting any errors at all. It all works just fine. But what am I
missing?

Thanks in advance


.
 
F

Fredrik

I have manage to solve this issue..
You had answeered someone else about embeeded files and I managed to change
the code in that one to get to my result.
And I trimed it abit to. So you don't need to save an draft and you will get
the Signature from boyt outlook 2007 and 2003. I think I manage that anyway.
Just let me know if you like to see how I did.

Many thanks for the suggestions what was wrong.

Best Regards
Fredrik.

Dmitry Streblechenko said:
If you are sending in the RTF format (which is very likely since you havea
custom message class), you will get the infamous winmail.dat attachment with
teh TNEF data, which only Outlook can understand.
Try to send a message to an account taht yo ucan access with OE and then
look at the meaasge source (*right click, Properties| Details | Message
Source).
--
Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
-
Fredrik said:
Okey. Feel that I have to add more info.

I just tried to see if the attached file will show up on hotmail. And it
does.
Then I am pretty chor about the file is sent aswell.

What is the different between adding a attachment by hand on Outlook 2007
and by adding it by script?
And what is the different in between, what is the different between adding
a
attachment by hand on Outlook 2003 and by adding it by script?

The code I am using is as following:

Const olMailItem = 0
Const olOriginator = 0
Const olByReference = 4
Const olByValue = 1
Const olEmbeddedItem = 5
Dim Outlook
Dim Message
Dim olFolderOutbox
Dim olFolderDrafts
Dim GetArgs
Dim I

olFolderOutbox = 4
olFolderDrafts = 16

On Error Resume Next
Set Outlook = GetObject(, "Outlook.Application")
If Outlook Is Nothing Then
Set Outlook = CreateObject("Outlook.Application")
End If
Err.Clear
On Error Goto 0

Set Message = Outlook.GetNameSpace("MAPI")._
GetDefaultFolder(olFolderDrafts)._
Items.Add("IPM.[Standard Forms Library].Message")

With Message
GetArgs = ""
GetArg "subject", GetArgs
.Subject = GetArgs

GetArgs = ""
GetArg "to", GetArgs
.Recipients.Add (GetArgs)

GetArgs = ""
GetArg "body", GetArgs
If Len(GetArgs) > 0 Then .Body = GetArgs

GetArgs = ""
GetArg "cc", GetArgs
If Len(GetArgs) > 0 Then .Cc = GetArgs

GetArgs = ""
GetArg "bcc", GetArgs
If Len(GetArgs) > 0 Then .Bcc = GetArgs

GetArgs = ""
GetArg "from", GetArgs
If Len(GetArgs) > 0 Then .Recipients.Add(GetArgs).Type = olOriginator
.Recipients.ResolveAll

.Save

For I = 1 To 5
GetArgs = ""
GetArg "attach" & CStr(I), GetArgs
If Len(GetArgs) > 0 Then
.attachments.Add GetArgs, 1, I
End If
Next

.Display
End With

Set Message = Nothing
Set Outlook = Nothing

'-----------------------------------------------------
' Checks the command line arguments for a given switch and returns the
associated
' string, if found. If not found, the defaultValue is returned instead.
Function GetArg( sSwitch, sDefaultValue )
Dim ArgCount, bMatch

ArgCount = 0
bMatch = 0

Do While ArgCount < WScript.arguments.length
If Eval((WScript.arguments.item(ArgCount)) = ("-" + (sSwitch))) Or
Eval((WScript.arguments.item(ArgCount)) = ("/" + (sSwitch))) Then
bMatch = 1
Exit do
Else
ArgCount = ArgCount + 1
End If
Loop

If ( bMatch = 1 ) Then
GetArgs = ( WScript.arguments.item(ArgCount + 1) )
Else
GetArgs = ( sDefaultValue )
End If

End Function


I'm not getting any errors at all. It all works just fine. But what am I
missing?

Thanks in advance


.
 
D

Dmitry Streblechenko

Did you end up using a standard message class (IPM.Note) or set the UseTnef
MAPI property to false?

--
Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
-
Fredrik said:
I have manage to solve this issue..
You had answeered someone else about embeeded files and I managed to
change
the code in that one to get to my result.
And I trimed it abit to. So you don't need to save an draft and you will
get
the Signature from boyt outlook 2007 and 2003. I think I manage that
anyway.
Just let me know if you like to see how I did.

Many thanks for the suggestions what was wrong.

Best Regards
Fredrik.

Dmitry Streblechenko said:
If you are sending in the RTF format (which is very likely since you
havea
custom message class), you will get the infamous winmail.dat attachment
with
teh TNEF data, which only Outlook can understand.
Try to send a message to an account taht yo ucan access with OE and then
look at the meaasge source (*right click, Properties| Details | Message
Source).
--
Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
-
Fredrik said:
Okey. Feel that I have to add more info.

I just tried to see if the attached file will show up on hotmail. And
it
does.
Then I am pretty chor about the file is sent aswell.

What is the different between adding a attachment by hand on Outlook
2007
and by adding it by script?
And what is the different in between, what is the different between
adding
a
attachment by hand on Outlook 2003 and by adding it by script?

The code I am using is as following:

Const olMailItem = 0
Const olOriginator = 0
Const olByReference = 4
Const olByValue = 1
Const olEmbeddedItem = 5
Dim Outlook
Dim Message
Dim olFolderOutbox
Dim olFolderDrafts
Dim GetArgs
Dim I

olFolderOutbox = 4
olFolderDrafts = 16

On Error Resume Next
Set Outlook = GetObject(, "Outlook.Application")
If Outlook Is Nothing Then
Set Outlook = CreateObject("Outlook.Application")
End If
Err.Clear
On Error Goto 0

Set Message = Outlook.GetNameSpace("MAPI")._
GetDefaultFolder(olFolderDrafts)._
Items.Add("IPM.[Standard Forms Library].Message")

With Message
GetArgs = ""
GetArg "subject", GetArgs
.Subject = GetArgs

GetArgs = ""
GetArg "to", GetArgs
.Recipients.Add (GetArgs)

GetArgs = ""
GetArg "body", GetArgs
If Len(GetArgs) > 0 Then .Body = GetArgs

GetArgs = ""
GetArg "cc", GetArgs
If Len(GetArgs) > 0 Then .Cc = GetArgs

GetArgs = ""
GetArg "bcc", GetArgs
If Len(GetArgs) > 0 Then .Bcc = GetArgs

GetArgs = ""
GetArg "from", GetArgs
If Len(GetArgs) > 0 Then .Recipients.Add(GetArgs).Type =
olOriginator
.Recipients.ResolveAll

.Save

For I = 1 To 5
GetArgs = ""
GetArg "attach" & CStr(I), GetArgs
If Len(GetArgs) > 0 Then
.attachments.Add GetArgs, 1, I
End If
Next

.Display
End With

Set Message = Nothing
Set Outlook = Nothing

'-----------------------------------------------------
' Checks the command line arguments for a given switch and returns the
associated
' string, if found. If not found, the defaultValue is returned instead.
Function GetArg( sSwitch, sDefaultValue )
Dim ArgCount, bMatch

ArgCount = 0
bMatch = 0

Do While ArgCount < WScript.arguments.length
If Eval((WScript.arguments.item(ArgCount)) = ("-" + (sSwitch)))
Or
Eval((WScript.arguments.item(ArgCount)) = ("/" + (sSwitch))) Then
bMatch = 1
Exit do
Else
ArgCount = ArgCount + 1
End If
Loop

If ( bMatch = 1 ) Then
GetArgs = ( WScript.arguments.item(ArgCount + 1) )
Else
GetArgs = ( sDefaultValue )
End If

End Function


I'm not getting any errors at all. It all works just fine. But what am
I
missing?

Thanks in advance


.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top