#  Other Applications & Softwares  > Outlook Formatting & Functions >  >  How to save email attachments with subject as a file name

## hudson andrew

Hi all ,

I have this code  brought from (Roni ) website that will save E-mail attachments from my inbox and save it to my local folder as given . however code is doing fine but I wanted  code to save my email attachment with email subject . below is the code for your reference .




```
Please Login or Register  to view this content.
```


appreciate your assistance .

----------


## NickyC

Hi
try changing the file saved name to 


```
Please Login or Register  to view this content.
```

----------


## hudson andrew

Hi all,

Thanks a lot . but above method gave me error message " Error number = 2147024809".

----------


## hudson andrew

hi can some one please advice . if there is a way we can do this , I have tried various possible ways but no luck .....

----------


## NickyC

Hi
ok try this. it's a simpler version so if things go wrong the cause should be easier to spot.




```
Please Login or Register  to view this content.
```

----------


## hudson andrew

Hey Nicky,

thanks Again.. it is very small than my code . however no luck . it is giving me error message " object required" for below line .

I have one quick question is the below line a selection item, the one I am trying to save with subject name  ?.


" Set MyItem = GetCurrentItem"

----------


## NickyC

getcurrentitem refers to the email with the attachments. the macro should save the attachments with a name that is the subject of that email, rather than the name of the attachment. 

To work, you should have the email message with the attachment you want to copy either selected or open. Is that perhaps the problem?

I have just tried it on a different computer and it worked fine.

----------


## hudson andrew

seems like i am missing something , i have tried once again ,  nothing happening , however i thought of sharing you some screen shots .. attached are the screen shot for your reference .

should this be running from excel or outlook ?... I am asking this because it worked for you .

----------


## hudson andrew

Hey Nicky , I just realized does above code  recognize PDF or any other  ?.  because i wanted above code to recognize PDF and save with subject name .

also let me know if i need to check any other references apart from " Microsoft office outlook object 14".

----------


## NickyC

Hi
the code should work with PDFs 
try with these references checked:
visual basic for applicationsMicrosoft outlookMicrosoft office

----------


## hudson andrew

Yes , I have above checked . but still same error ... I wonder how it worked with you ..

----------


## NickyC

are you in an outlook folder with a mail item selected that has attachments?
If so, the only thing I can think of is that it is not specifying that MyItem is a mail item.

try changing 




```
Please Login or Register  to view this content.
```




to 




```
Please Login or Register  to view this content.
```

----------


## hudson andrew

are you in an outlook folder with a mail item selected that has attachments? " yes I am ."

I tried changing it , another failure it did not work .. Nicky are you sure it worked with you ?.

----------

